Home >Backend Development >PHP Tutorial >php array element taking function

php array element taking function

WBOY
WBOYOriginal
2016-07-29 09:04:461247browse
<?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.

Statement:
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