代码如下
<?phpfunction Contrast($arr,$r,$c,&$numb){ if($arr[$r][$c]==$arr[$r][$c+1]){ $c++; $numb++; Contrast($arr,$r,$c,$numb); }else{ echo $numb."</br>"; return $numb; }}$arr=array(array(0,0,0,1,1,1,1,1,1,0,0,));$r=0;$c=3;$numb=0;$d=Contrast($arr,$r,$c,$numb);var_dump($d);?>
第6行 加上return :return Contrast($arr,$r,$c,$numb);
??分支的???有返回值
if($arr[$r][$c]==$arr[$r][$c+1]){ $c++; $numb++; Contrast($arr,$r,$c,$numb); }else{
<?phpfunction Contrast($arr,$r,$c,&$numb){ if($arr[$r][$c]==$arr[$r][$c+1]){ $c++; $numb++; return Contrast($arr,$r,$c,$numb); }else{ echo $numb."</br>"; return $numb; }} $arr=array(array(0,0,0,1,1,1,1,1,1,0,0,));$r=0;$c=3;$numb=0;$d=Contrast($arr,$r,$c,$numb);var_dump($d);?>
谢谢各位大神 已经想明白了!~~~~