小问题:
$content='/p test some text';当"/p“在行前面时,字符串应该被爆破成一个数组。
if(preg_match('^(/p)',$content)==true) {
$private=explode(" ",$content,3);
}我认为它们是一个错误,但我不知道正确的搜索参数
发布于 2015-03-01 14:43:02
这应该适用于你:
(不需要将其与true进行比较,因为如果没有找到任何内容,则返回一个空数组,然后该数组为false。此外,您还需要定界符作为正则表达式,并使用反斜杠转义斜杠)
$content='/p test some text';
if(preg_match('/^\/p/',$content)) {
//^ ^ See delimiters
$private=explode(" ",$content,3);
}发布于 2015-03-01 14:44:33
为什么不是一个简单的测试
if ($content{0} == '/' && $content{1} == 'p' ) {
$private=explode(" ",$content,3);
} https://stackoverflow.com/questions/28794786
复制相似问题