note 14645 added to function.array-shift.php

From: Date: Tue, 07 Aug 2001 19:01:33 +0000
Subject: note 14645 added to function.array-shift.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-16449@lists.php.net to get a copy of this message
Here's an array_shift that keeps the keys intact. It's called exactly the same way that array_shift() is. function my_array_shift(&$array) { //and array_shift that keeps the //keys intact! reset($array); $i = 0; $newArray = array(); while(list($key, $val) = each($array)) { if ($i > 0) { $newArray[$key] = $val; } else { $toReturn = $array[$key]; } $i++; } $array = $newArray; return $toReturn; } //end my_array_shift http://www.php.net/manual/en/function.array-shift.php

« previous php.notes (#16449) next »