note 14358 added to function.array-unshift.php

From: Date: Fri, 27 Jul 2001 16:21:56 +0000
Subject: note 14358 added to function.array-unshift.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-15944@lists.php.net to get a copy of this message
If you need to prepend something to the array without the keys being reindexed and/or need to prepend a key value pair, you can use this short function: function array_unshift_assoc(&$arr, $key, $val) { $arr = array_reverse($arr, true); $arr[$key] = $val; $arr = array_reverse($arr, true); return count($arr); } http://www.php.net/manual/en/function.array-unshift.php

« previous php.notes (#15944) next »