1.函数的作用:遍历数组元素
2.函数参数:
@params array &$array
3.例子:
1 <?php 2 $arr = [‘Boy‘,‘Girl‘]; 3 while(list($key,$value) = each($arr)){ 4 echo ‘key : value => ‘ .$key. ‘ : ‘ .$value; 5 echo "\n"; 6 if(mt_rand(0,1) >= 0.5){ 7 break; 8 } 9 } 10 $sex = current($arr); 11 if($sex){ 12 echo "Hi,Zby! It‘s a $sex!\n"; 13 echo ‘You are kidding me.It must not be a Boy!‘; 14 }else{ 15 echo "It‘s God Like!"; 16 }
时间: 2024-10-05 04:24:40