Home  >  Article  >  Backend Development  >  Detailed explanation of usage examples of PHP array operation functions current, next and reset functions

Detailed explanation of usage examples of PHP array operation functions current, next and reset functions

怪我咯
怪我咯Original
2017-06-06 11:41:291998browse

What are the uses of php current, next and reset functions?

The current() function in php returns the current element (unit, which is the first element of the array) in the array. The next() function points the internal pointer to the next element in the array, and Output the value of the element. The reset() function points the internal pointer to the first element in the array and outputs the value of the element. This article mainly introduces the usage of current, next and reset functions in PHP, with examples. This article describes the specific usage of the functions current, next and reset for array operations in PHP. It has certain reference value for in-depth understanding of the usage of arrays. I hope it will be helpful to everyone's understanding of arrays

current function

current() function returns the value of the current element in the array. Each array has an internal pointer pointing to its "current" element, initially pointing to it. Inserts the first element into the array. This function does not move the array internal pointer

Example##

";
?>

Code running result:

Detailed explanation of usage examples of PHP array operation functions current, next and reset functions

next function

next() function points the internal pointer to the next in the array element, and output the value of the element.

Example

Use php current and next functions to output the value of the current element and the next element in the array: The code is as follows

";
echo next($people);
?>

Code running result:

Detailed explanation of usage examples of PHP array operation functions current, next and reset functions

#reset function

set() function is to point the internal pointer to the array The first element in the array, and output the value of the element.

Example

Use the php current and next functions to output the value of the current element and the next element in the array, and then put the array The internal pointer is reset to the first element in the array. The code is as follows

";
echo next($people) . "
"; echo reset($people); ?>

Code running result:

Detailed explanation of usage examples of PHP array operation functions current, next and reset functions

##[Related article recommendations]

php array function current() definition and usage

Detailed explanation of php end() function and current() function

The above is the detailed content of Detailed explanation of usage examples of PHP array operation functions current, next and reset functions. For more information, please follow other related articles on the PHP Chinese website!

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