Home  >  Article  >  Backend Development  >  Get the value of the first element of the unknown character key name array through the PHP current function_PHP tutorial

Get the value of the first element of the unknown character key name array through the PHP current function_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:03:11795browse

About the current() function:

Each array has an internal pointer pointing to its "current" unit, which initially points to the first unit inserted into the array. Get it with current().

Similar functions:

end() Moves the array's internal pointer to the last cell and returns its value.

next() returns the value of the next cell pointed to by the array's internal pointer, or FALSE when there are no more cells.

prev() returns the value of the previous cell pointed to by the internal pointer of the array, or returns FALSE when there are no more cells.

reset() Rewinds the internal pointer of array to the first cell and returns the value of the first array cell, or FALSE if the array is empty.

Look at the following PHP case:

Copy the code The code is as follows:

$arr = array("a"=>"php","java","c");
echo current($arr); //php
echo next($arr); //java
echo prev($arr); //php points to the value of the previous unit, so it is php again
echo end($arr); //c
?>


Several very useful and useful php functions, I have memorized them anyway.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327867.htmlTechArticleAbout the current() function: Each array has an internal pointer pointing to its "current" unit, Initial points to the first element inserted into the array. Get it with current(). Similar functions...
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