note 94754 modified in function.array-push by danbrown

From: Date: Mon, 23 Nov 2009 15:34:15 +0000
Subject: note 94754 modified in function.array-push by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-163194@lists.php.net to get a copy of this message
If you want to preserve the keys in the array, use the following: <?php function array_pshift(&$array) { $keys = array_keys($array); $key = array_shift($keys); $element = $array[$key]; unset($array[$key]); return $element; } ?> --was-- If you want to preserve the keys in the array, use the following: <? function array_pshift(&$array) { $keys = array_keys($array); $key = array_shift($keys); $element = $array[$key]; unset($array[$key]); return $element; } ?> http://php.net/manual/en/function.array-push.php

« previous php.notes (#163194) next »