Home  >  Article  >  Backend Development  >  How to use the function end() in php to access the last element of the array, array end_PHP tutorial

How to use the function end() in php to access the last element of the array, array end_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:02:59984browse

How to use the function end() in PHP to access the last element of an array, array end

The example in this article describes the usage of the function end() in PHP to access the last element of an array. Share it with everyone for your reference. The specific analysis is as follows:

The

end() function is used in PHP to retrieve the last element in an array. The end() function requires an array as its only argument and returns the element value of the last element of the given array.

$users = array ("baidu.com", "haosou.com", "sina.com", "jb51.net");
print end($users);

The above code returns: jb51.net

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969482.htmlTechArticleUsage of function end() in php to access the last element of the array, array end This article describes the example of php accessing the last element of the array Function end() usage of elements. Share it with everyone for your reference. Specifically...
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