PHP array_shift() not working for me. What am I doing wrong? -
i creating array , want delete first element of array , re-index it. can tell, array_shift() right solution. however, not working in implementation.
i have member variable of class defined array called $waypoint_city. here variable output prior shifting array:
print_r($this->waypoint_city);
result:
array ( [0] => [1] => jacksonville [2] => orlando [3] => montgomery [4] => memphis )
if following, correct result:
print_r(array_shift($this->waypoint_city));
result:
array ( [0] => jacksonville [1] => orlando [2] => montgomery [3] => memphis )
however, if try reassign result member variable doesn't work... know why is?
$this->waypoint_city = array_shift($this->waypoint_city);
if try print_r($this->waypoint_city) looks nothing in there. can save hair haven't pulled out, yet.
array_shift
[docs] changes array in-place. returns first element (which empty in case):
returns shifted value, or
null
if array empty or not array.
all have is:
array_shift($this->waypoint_city);
Comments
Post a Comment