PHP Array Function : array_pop()

The array_pop() function is used to delete or remove the last element of an array. The syntax is as follows :
 array_pop(array);
Where array specifies the name of array.

Example :
<?php

  $my_arr = array("HTML", "CSS", "JavaScript", "PHP", "MySql", "JSP");
 
  $len = count($my_arr);
  for($x = 0; $x < $len; $x++) {
    echo $my_arr[$x] . ", ";
  }

  array_pop($my_arr);
  echo "<br/><br/>After array_pop() : <br/><br/>";

  $len = count($my_arr);
  for($x = 0; $x < $len; $x++) {
    echo $my_arr[$x] . ", ";
  }

?>
Output :

HTML, CSS, JavaScript, PHP, MySql, JSP,

After array_pop() :

HTML, CSS, JavaScript, PHP, MySql,


Next Topic :