How to use end in PHP
In this article, I will explain how the end() function can be used in PHP.
end() function in PHP
-
The end() function is used to move the internal pointer to, and outputs, the last element in the array.
-
The end() function returns the value of the last element in the array element.
Syntax
Parameter
- array array is required parameter. it is the input array to use.
Example
The following example show to how the end() function can be used in PHP.
<html>
<body>
<h3 style="color: seagreen;">end() function example in PHP</h3>
<?php
$subject_list = array('Hindi', 'Math', 'English', 'Computer');
$subject = current($subject_list);
echo("Current function value : ");
print "$subject <br />";
$subject = next($subject_list);
echo("next function value : ");
print "$subject <br />";
$subject = prev($subject_list);
echo("pre function value : ");
print "$subject <br />";
$subject = end($subject_list);
echo("end function value : ");
print "$subject <br />";
?>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here