我想将一个包含
下一个函数目前还不能正确运行。
输出应该是:
什么样的模式可以完成它? 编辑 如果有多个标签,该怎么办?
输出应该是:
<p>
标签的字符串分割成不同的部分。$string = 'Text <img src="hello.png" /> other text.';
下一个函数目前还不能正确运行。
$array = preg_split('/<img .*>/i', $string);
输出应该是:
array(
0 => 'Text ',
1 => '<img src="hello.png" />',
3 => ' other text.'
)
什么样的模式可以完成它? 编辑 如果有多个标签,该怎么办?
$string = 'Text <img src="hello.png" > hello <img src="bye.png" /> other text.';
$array = preg_split('/(<img .*>)/i', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
输出应该是:
array (
0 => 'Text ',
1 => '<img src="hello.png" />',
3 => 'hello ',
4 => '<img src="bye.png" />',
5 => ' other text.'
)