PHP 数组current和next用法分享

本文这里通过示例给大家简单对比分析了PHP
数组current和next的用法,虽然示例很简单,但是对于我们理解current和next非常有帮助,这里推荐给大家。

PHP 数组current和next用法分享,currentnext

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

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

数组current和next用法分享,currentnext
1.current 复制代码 代码如下: php $transport = array(‘foot’, ‘bike’,
‘car’, ‘plane’); $mode = current($transport); //$mode…

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

发表评论

电子邮件地址不会被公开。 必填项已用*标注

相关文章

网站地图xml地图