PHP 数组current和next用法分享

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

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

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgfgdx.html