How to use reset function

藏色散人
Release: 2023-04-05 07:18:02
Original
3846 people have browsed it

PHP reset() function points the internal pointer of the array to the first unit.

How to use reset function

php reset() function Syntax

Function: Point the internal pointer to the first element in the array and output it.

Syntax:

reset(array)
Copy after login

Parameters:

array Required. Specifies the array to use.

Description: If successful, return the value of the first element in the array, if the array is empty, return FALSE.

php reset() function example 1

<?php
$people = array("西门", "灭绝", "无忌");
echo end($people); //指向最后一个元素 无忌
echo "<br>";
echo reset($people); //指向数组中第一个元素 西门
?>
Copy after login

Output:

无忌
西门
Copy after login

php reset() function example 2

<?php
$people = array("欧阳克", "无忌", "Peter_zhu");
echo end($people); //指向最后一个元素 Peter_zhu
echo "<br>";
echo reset($people); //指向数组中第一个元素 欧阳克
?>
Copy after login

Output:

Peter_zhu
欧阳克
Copy after login

This article is an introduction to the PHP reset function. I hope it will be helpful to friends in need!

The above is the detailed content of How to use reset function. For more information, please follow other related articles on the PHP Chinese website!

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