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)。如果我要對該數組執行計數,那麼我仍然只能得到一個變量,對嗎? –