【发布时间】:2012-12-12 03:48:15
【问题描述】:
我现在正在制作一个新闻和评论系统,但我现在被困在一个部分上一段时间了。我希望用户能够以 @username 之类的 twitter 样式引用其他玩家。脚本看起来像这样:(不是真正的 PHP,只是想象脚本;3)
$string = "I loved the article, @SantaClaus, thanks for writing!";
if($string contains @){
$word = word after @;
$check = is word in database? ...
}
对于字符串中的所有@username,可能使用while() 来完成。我卡住了,请帮忙。
【问题讨论】:
-
在这种情况下,RegEx 没有问题,您可能需要检查preg_match()
-
传闻人们称之为伪代码
-
@Alexander - 不过我有点喜欢。 Imagination 脚本。 “你做什么工作,Alex?” “想象力脚本。”O_o'