数组current和next用法分享

 百家乐-前端     |      2020-04-07 22:44

正文这里透过示范给大家简单比较剖析了PHP 数组current和next的用法,尽管示例很简短,然而对于大家驾驭current和next非常常有赞助,这里推荐给我们。

百家了乐八大技巧lom599乐百家手机 ,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';
 ?>

示范很简单,不过却很实用,希望小同伙们可以欣赏。