php约瑟夫环
<?php function popChar($str , $m , $current = 0){ $number = count($str); $num = 1; if(count($str) == 1){ echo $str[0]; return; } else{ while($num++ < $m){ $current++ ; $current = $current%$number; } echo $str[$current]."<br/>"; array_splice($str , $current , 1); popChar($str , $m , $current); } } //$str = array(1 , 2 , 3 , 4 , 5 , 6 , 7, 8 , 9 , 10); $str = array('a','b','c','d','e','f','g','h'); $m = 4; popChar($str , $m); ?>