end() function in PHP || PHP End Function

end() function in php

Last Updated by Pooja Chikara

0 2991

PHP end() function is used to move the current pointer of the array to the end and return the value on that position. It is an inbuilt function of PHP.

Syntax:

end($array);

here,

$array is a PHP array.


Example:

<?php
$arr1 = array("apple","orange","banana","fig",);
$last_value=end($arr1);  // it will return the last item of array i.e. fig
echo "last item of array is $last_value <br>";
?>

Output:

Note: You should also read prev(), next(), current() and reset() functions.



Best WordPress Hosting


Share:

SSL for business, from $12.88


Leave a Reply


Comments
    Waiting for your comments

Coding Tag WhatsApp Chat
Coding Tag WhatsApp Chat