Home >Backend Development >PHP Tutorial >求大侠帮忙
123456的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"/> ))
$s='1234<IMG SRC="74.swf"/>56的78<IMG SRC="68.swf"/>';preg_match_all('/([^<>]+|<[^>]+>)/', $s, $m);print_r($m[0]);