- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
end() function in PHP
The end() function sets the internal pointer of an array to its last element
Syntax
end(arr)
Parameters
arr − The specified array
Return
The end() function returns the value of the last element in the array, on success. It returns FALSE, if the array is empty.
Example
The following is an example −
<?php $os = array('windows', 'mac', 'linux', 'solaris'); echo end($os); ?>
Output
The following is the output −
solaris
Example
Let us see another example −
<?php $a = array('one', 'two', 'three', 'four', 'five', 'six' ); echo current($a)."
"; echo next($a)."
"; echo current($a)."
"; echo end($a)."
"; echo current($a)."
"; ?>
Output
The following is the output −
one two two six six
Advertisements
To Continue Learning Please Login
Login with Google