Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,我有这样的文字:
<content>Foo</content>This is only a <b>test</b><content>Bar</content>Again, only a test.
如何创建一个包含两个条目的数组,Foo并且Bar?
Foo
Bar
preg_match_all("/<content>(.+?)<\/content>/is", $string, $matches);
您的结果将被放入$matches数组中。
$matches
$matches[0]使用、等访问它们$matches[1]。
$matches[0]
$matches[1]
祝你好运!
编辑:preg_match_all()会给你所有的结果!感谢@Blake 的提示。
preg_match_all()