Page 1 of 1

Array Shift

Posted: Tue Mar 14, 2006 5:57 pm
by ek5932
Hi, I have been browsing through the PHP website and I am not quite sure why this dosnt work. I am trying to shift my array and then add a 0 on the end. the code I have is:

Code: Select all

$unpack = explode("|",$row[$type[$counter][name]]);
$unpack = array_shift($unpack);
$unpack[] = 0;
array shift dosn't actually shift the array it just displays the first value in the array. any help would be great, thanks.

Posted: Tue Mar 14, 2006 6:04 pm
by feyd
you're "destroying" $unpack when you set it from array_shift(). array_shift() does shift the array, the array passed to it and returns the element shifted out of the array.