php数组current和next的用法,二个例子,方便大家理解current和next的使用方法。
php数组 current和next的用法
1、current取php数组当前值
<?php
$transport=array('foot','bike','car','plane');
$mode=current($transport);//$mode='foot';
$mode=next($transport); //$mode='bike';
$mode=current($transport);//$mode='bike';
$mode=prev($transport); //$mode='foot';
$mode=end($transport); //$mode='plane';
$mode=current($transport);//$mode='plane';
?>
2、next取php数组下一个值
<?php
$transport=array('foot','bike','car','plane');
$mode=current($transport);//$mode='foot';
$mode=next($transport); //$mode='bike';
$mode=next($transport); //$mode='car';
$mode=prev($transport); //$mode='bike';
$mode=end($transport); //$mode='plane';
?>