【发布时间】:2014-12-10 21:53:00
【问题描述】:
我目前正在我网站的个人资料页面中制作标签系统。如果用户指定:+tag[username],其中 username 等于该人的好友用户名,它将 preg_replace 将标签替换为指向用户的链接。使用 strpos 查找 +tag 很容易,但我要问的问题是如何将用户名作为变量提取。例如:如果 $text = '嘿 +tag[matty] 你好吗!'
if (strpos($text, '+tag[//username//]' !== false)) {
//get //username// and store as $username
}
让它看起来像这样:
if (strpos($text '+tag[//username//]' !== false) {
$username = "matty";
}
感谢所有提前回复的人:)
【问题讨论】: