<?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;
?>
posted on 2017-08-09 17:25  丶焦人  阅读(592)  评论(0编辑  收藏  举报