$char = "<div>11111</div><div>22222</div><div>33333</div>";preg_match_all("|<div>(.*)</div>|U", $char, $out,PREG_PATTERN_ORDER);echo $out[0][0];echo $out[0][1];echo $out[0][2];
补充:div之间有中文字符
$char = "<div>11111</div><div>22222</div><div>33333</div>";$ary = explode('<div>', $char);shuffle($ary);foreach($ary as $v){ echo '<div>'.$v;}
$char = "
谢谢楼上的两位大哥,这是一个循环
那怎么把这个值重新放到字符串里
比如$char1 = ''
代码应当怎么写,小弟不怎么懂php的,再麻烦下,谢谢了
$char = "<div>11111</div><div>22222</div><div>33333</div>";preg_match_all("|<div>(.*)</div>|U", $char, $out,PREG_PATTERN_ORDER);shuffle($out[0]);$s= join('',$out[0]);echo $s;
靠
用5楼的代码
$char = "<div>11111</div><div>22222</div><div>33333</div>";preg_match_all("|<div>(.*)</div>|U", $char, $out,PREG_PATTERN_ORDER);shuffle($out[0]);$char= join('',$out[0]);echo $char;