Home  >  Article  >  Backend Development  >  php end function and current function

php end function and current function

WBOY
WBOYOriginal
2016-07-29 09:14:421243browse

end() function: The

end() function points the pointer inside the array to the last element, and returns the value of the element if successful;

for example:

<code><span>$people</span> = <span>array</span>(<span>"Peter"</span>, <span>"Joe"</span>, <span>"Glenn"</span>, <span>"Cleveland"</span>);
<span>echo</span> end(<span>$people</span>);</code>

output: Cleveland

current () function:

current() function returns the current element (unit) in the array.
Each array has an internal pointer that points to its "current" element, initially pointing to the first element inserted into the array.

**Note: If there is an empty element, or the element has no value, this function also returns FALSE.
Tip: This function does not move the internal pointer. To do this, use the next() and prev() functions. **

For example:

<code><span>$people</span> = <span>array</span>(<span>"Peter"</span>, <span>"Joe"</span>, <span>"Glenn"</span>, <span>"Cleveland"</span>);
<span>echo</span> current(<span>$people</span>);</code>

output: Peter

The above introduces the PHP end function and current 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
Previous article:mac installation php56Next article:mac installation php56