top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is use of end function in PHP?

+1 vote
456 views
What is use of end function in PHP?
posted Jun 9, 2014 by Rahul Mahajan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

The end() function moves the internal pointer to, and outputs, the last element in the array.

Example:

<?php
$people = array("vrije", "rahul", "amit", "jai");

echo current($people) ;
echo end($people);
?> 

Output:

vrije
jai
answer Jun 10, 2014 by Vrije Mani Upadhyay
0 votes

End function can set the pointer of an array to the last element of array.

e.g :
<?php $arr = array('name'=>'angel','age'=>'23','city'=>'delhi','profession'=>'php developer'); $lastValue = end($arr); ?>

OUTPUT : php developer .

answer Jun 10, 2014 by Mohit Sharma
...