[Solved] Why is array_pop() returning the last item of the array instead of deleting it? [closed]


Problem

You are doing the pop operation correctly, but immediately you are assigning the currently removed element to the variable $blam. So it iffectively makes that variable hold the value i.e the element that was popped.

Solution

Don’t assign the value returned by pop function to the variable.

Code

$blam = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$blam = explode("https://stackoverflow.com/", $blam); 
array_pop($blam);
print_r($blam);

solved Why is array_pop() returning the last item of the array instead of deleting it? [closed]