PHP array function current and next usage sharing

PHP中文网
Release: 2023-02-28 21:38:02
Original
1257 people have browsed it

This article gives you a simple comparative analysis of the usage of PHP arrays current and next through examples. Although the example is very simple, it is very helpful for us to understand current and next. It is recommended to everyone here.

1.current

<?php
$transport = array(&#39;foot&#39;, &#39;bike&#39;, &#39;car&#39;, &#39;plane&#39;);
$mode = current($transport); //$mode = &#39;foot&#39;;
$mode = next($transport); // $mode =&#39;bike&#39;;
$mode = current($transport); //$mode = &#39;bike&#39;;
$mode = prev($transport); // $mode =&#39;foot&#39;;
$mode = end($transport); // $mode =&#39;plane&#39;;
$mode = current($transport); //$mode = &#39;plane&#39;;
?>
Copy after login

2.next

<?php
$transport = array(&#39;foot&#39;, &#39;bike&#39;, &#39;car&#39;, &#39;plane&#39;);
$mode = current($transport); //$mode = &#39;foot&#39;;
$mode = next($transport); // $mode =&#39;bike&#39;;
$mode = next($transport); // $mode =&#39;car&#39;;
$mode = prev($transport); // $mode =&#39;bike&#39;;
$mode = end($transport); // $mode =&#39;plane&#39;;
?>
Copy after login

The example is very simple, but very practical. I hope your friends will like it.

The above has introduced the usage sharing of PHP array current and next, including the content of current and next. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template