求大侠帮忙

WBOY
WBOYOriginal
2016-06-23 13:56:521050browse

1234求大侠帮忙56的78求大侠帮忙

怎么把上面这个段字符串分割成

1234
求大侠帮忙
56的78
求大侠帮忙

这样的数组


回复讨论(解决方案)

$str='1234<IMG SRC="74.swf"/>56的78<IMG SRC="68.swf"/>';$arr1=preg_split('/<.*>/U',$str);array_pop($arr1);preg_match_all('/<.*>/U',$str,$arr2);$arr3=array_merge($arr1,$arr2);print_r($arr3);


Array(    [0] => 1234    [1] => 56的78    [2] => Array        (            [0] => <IMG SRC="74.swf"/>            [1] => <IMG SRC="68.swf"/>        ))

$str='1234<IMG SRC="74.swf"/>56的78<IMG SRC="68.swf"/>';$arr1=preg_split('/<.*>/U',$str);array_pop($arr1);preg_match_all('/<.*>/U',$str,$arr2);$arr3=array_merge($arr1,$arr2);print_r($arr3);


Array(    [0] => 1234    [1] => 56的78    [2] => Array        (            [0] => <IMG SRC="74.swf"/>            [1] => <IMG SRC="68.swf"/>        ))


谢谢大侠,可以按顺序吗。
必须
(1)1234
(2)求大侠帮忙
(3)56的78
(4)求大侠帮忙
这样的顺序

$s='1234<IMG SRC="74.swf"/>56的78<IMG SRC="68.swf"/>';preg_match_all('/([^<>]+|<[^>]+>)/', $s, $m);print_r($m[0]);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:菜鸟,json输出Next article:求高效算法找