How to use end in PHP

In this article, I will explain how the end() function can be used in PHP.
  • 1484

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.




  • array array is required parameter. it is the input array to use.


The following example show to how the end() function can be used in PHP.



<h3 style="color: seagreen;">end() function example in PHP</h3>


    $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 />";






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


More Articles

© 2020 DotNetHeaven. All rights reserved.