<?php
//初始化。
$test = "";
$num = 1;
$res = null;
//获取一个数组。
$chars = array('A','B','C','D','E','F');
for($n=0;$n<9;$n++){
$key=array_rand($chars,1);
$test = $test.$chars[$key];
}
// print_r($test);die;
//获取数组长度。
$length=strlen($test);
//开始计算。
for($i=0;$i<$length;$i++){
$a = substr($test,$i,1);
$b = substr($test,$i+1,1);
if($a==$b){
$num++;
}else{
$res = $res.$num.$a;
$num = 1;
}
}
echo $res;
?>
转载于:https://www.cnblogs.com/ssjzw/p/7327567.html