note 25317 added to function.array-pad
| From: | mwwaygoo at hotmail dot com | Date: | Thu, 19 Sep 2002 14:39:38 +0000 |
| Subject: | note 25317 added to function.array-pad | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-36956@lists.php.net to get a copy of this message | ||
OR you could do this
$myArr = array(2 => 'three', 3 => 'four');
$newArr = array_pad(array(), 4, 'FILLED');
$newArr =$myArr+$newArr;
This gives your desired result BUT the ordering is a little wierd, because of the order they were
added. Indexes are okay though and that is what you wanted.
print_r($newArr) outputs
Array ( [2] => three [3] => four [0] => FILLED [1] => FILLED )
hope this helps
--
http://www.php.net/manual/en/function.array-pad.php
http://master.php.net/manage/user-notes.php?action=edit+25317
http://master.php.net/manage/user-notes.php?action=delete+25317
http://master.php.net/manage/user-notes.php?action=reject+25317