PHP array_​pop Function

array_​pop () is a prebuilt / default array function of PHP, This function is basically allows user to delete the last element of any existing array. By using this function user can short the array by one element

Syntax of array_pop () :


array (Required) – element is required and it specifies an array.

Return Value :
it will return the last value of array. If will through error if array is empty. and if its not an array it will return NULL.

Example 1 :

     $watches = array("Rolex", "Omega", "Tuder", "Panerai", "Cartier");  
     $watch_new = array_pop($watches);  

Output will be : Cartier

Example 2 : With Simple array.

     $watches = array("Rolex", "Omega", "Tuder", "Panerai", "Cartier");  

Output will be :

  [0] => Rolex 
  [1] => Omega 
  [2] => Tuder 
  [3] => Panerai 

In the previous post I described regarding the PHP array_​push Function

Hope this article helps you in PHP development and understandings of Array. Stay tuned for more PHP Tutorials, Hope you enjoyed reading, if you need the professional PHP, PHP Framework and Magento 2 Development we can help you, just Click on the Link and send me your requirements.