例如,我有以下文本:
<content>Foo</content>This is only a <b>test</b><content>Bar</content>Again, only a test.
如何创建一个包含两个条目的数组,Foo
和 Bar
?
preg_match_all("/<content>(.+?)<'/content>/is", $string, $matches);
您的结果将被放入$matches
数组中。
使用 $matches[0]
、 $matches[1]
等访问它们。
祝你好运!
编辑:preg_match_all()
将为您提供所有结果!感谢@Blake的小费。