时间:2021-07-01 10:21:17 帮助过:5人阅读
$char = "111112222233333";preg_match_all("|(.*)|U", $char, $out,PREG_PATTERN_ORDER);echo $out[0][0];echo $out[0][1];echo $out[0][2];
补充:div之间有中文字符
$char = "111112222233333";$ary = explode('', $char);shuffle($ary);foreach($ary as $v){ echo ''.$v;}
$char = "111112222233333";
$ary = explode('', $char);
shuffle($ary);
foreach($ary as $v)
{
if($v!=""){
echo ''.$v;
}
}
楼上的加个判断值不为空更好点,数组后面会多循环一次,后面会多带个
谢谢楼上的两位大哥,这是一个循环
那怎么把这个值重新放到字符串里
比如$char1 = ''
代码应当怎么写,小弟不怎么懂php的,再麻烦下,谢谢了
$char = "111112222233333";preg_match_all("|(.*)|U", $char, $out,PREG_PATTERN_ORDER);shuffle($out[0]);$s= join('',$out[0]);echo $s;
靠
用5楼的代码
$char = "111112222233333";preg_match_all("|(.*)|U", $char, $out,PREG_PATTERN_ORDER);shuffle($out[0]);$char= join('',$out[0]);echo $char;