How to delete the last element from array in PHP

1 Answer

0 votes
$arr = array("php", "c", "c++", "c#", "python", "java");

array_splice($arr, -1, 1);

print_r($arr);



/*
run:

Array
(
    [0] => php
    [1] => c
    [2] => c++
    [3] => c#
    [4] => python
)

*/

 



answered Dec 8, 2020 by avibootz

Related questions

...