Home >Backend Development >PHP Tutorial >php array element taking function
<?php $people = array("Bill", "Steve", "Mark", "David"); echo current($people) . "<br>"; <span>// 当前元素是 Bill</span> echo next($people) . "<br>"; <span>// Bill 的下一个元素是 Steve</span> echo current($people) . "<br>"; <span>// 现在当前元素是 Steve</span> echo prev($people) . "<br>"; <span>// Steve 的上一个元素是 Bill</span> echo <code>end($people)</code> . "<br>"; <span>// 最后一个元素是 David</span> echo prev($people) . "<br>"; <span>// David 之前的元素是 Mark</span> echo current($people) . "<br>"; <span>// 目前的当前元素是 Mark</span> echo reset($people) . "<br>"; <span>// 把内部指针移动到数组的首个元素,即 Bill</span> echo next($people) . "<br>"; <span>// Bill 的下一个元素是 Steve</span>print_r (each($people)); <span>// 返回当前元素的键名和键值(目前是 Steve),并向前移动内部指针</span> ?>
The above introduces the PHP array element fetching function, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.