How to remove last element of an array in PHP - Coding Cyber

How to remove last element of an array in PHP

How to remove last element of an array in PHP, We can remove last element of an array using array_pop function in php. First we are using an array with sample values, then we are assigning it to an $array variable, before applying the function we are printing array with print_r function surrounded with pre tags, this pre tag will display an array in human readable manner. After that we are using array_pop by simply passing the array, after applying the function we are again printing the array surrounded with pre tags.

[php] <?php
$array = array(‘hi’, ‘this’, ‘is’, ‘an’, ‘array’);
echo "<pre>";
print_r($array);

array_pop($array);
print_r($array);
echo "</pre>";
?>
[/php]


https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1831 y2w_j8KhncrmudxYux-FAo0Z2EtJGW2lLaXqp21ynfh8mLGQR3bnSa3e5vh1KYS5 a0199ab28ca0400de8491b4b1c6e22186cdb6fec&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme php remove the last element of an array
Vivek Vengala
 

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: