欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

PHP 数组current和next用法

程序员文章站 2022-04-07 09:31:53
...

1.current 当前数组 ?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);

1.current 当前数组

$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 下一个数组

$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';
?>