首页 热点资讯 义务教育 高等教育 出国留学 考研考公
您的当前位置:首页正文

PHP数组current和next用法分享_基础知识

2020-11-27 来源:华佗小知识

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); // $mode ='foot';
$mode = end($transport); // $mode ='plane';
$mode = current($transport); //$mode = 'plane';
?>

2.next

代码如下:
<?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';
?>

示例很简单,但是却很实用,希望小伙伴们能够喜欢。

显示全文