1
我有在许多“简码”的字符串这样(只用一个例子):检查正则表达式PHP的
$str = "[video src="http://www.aaa..." options="autoplay controls loop mute"]\n
[video src=" http://www.bbb..." options="autoplay controls loop mute"]";
我想每一个independantly使用的preg_match从而匹配():
pregmatch('/\[video.*\]/', $str, $matches);
现在我预计count($matches);
返回'2'。但是我每次只得到1个。我的正则表达式是否错误?我需要分配每个[video ...... ]
到一个新的数组项目,所以我可以单独处理它们。
感谢
啊,我明白了。谢谢。为什么它嵌套数组(1)中的每个匹配。我期待看到它自己的数组(2)。如果我要对该数组执行计数,那么我仍然只能得到一个变量,对吗? –