The php reset() function pointer points to the first element in the array and outputs the example code

高洛峰
Release: 2023-03-03 13:08:01
Original
1294 people have browsed it

The reset function points the internal pointer of the array to the first element and outputs the array.

Basic syntax

reset(array)

reset() rewinds the internal pointer of array to the first cell and returns the value of the first array cell.

Parameter introduction:

The php reset() function pointer points to the first element in the array and outputs the example code

Return value

Returns the value of the first unit of the array, or FALSE if the array is empty.

Example

<?php
 
$array = array(&#39;step one&#39;, &#39;step two&#39;, &#39;step three&#39;, &#39;step four&#39;);
 
// 数组默认指针指向第一个元素
echo current($array)."<br />";
 
// 将指针指向下一个元素
next($array);
next($array);
echo current($array)."<br />";
 
// 将指针指向重新指向第一个元素
reset($array);
echo current($array)."<br />";
?>
Copy after login

Running result:

step one
step three
step one


Related labels:
php
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!