note 30609 added to function.array-pad
| From: | goffrie at sympatico dot ca | Date: | Sun, 23 Mar 2003 23:06:54 +0000 |
| Subject: | note 30609 added to function.array-pad | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45703@lists.php.net to get a copy of this message | ||
To daarius - you mean you have...
[2]=>"two"
[3]=>"three"
and you want...
[0]=>"FILLED"
[1]=>"FILLED"
[2]=>"two"
[3]=>"three"
[4]=>"FILLED"
[5]=>"FILLED"
If so, then the following code...
$array = array(2 => "two", 3 => "three");
$array = array_pad($array, count($array)+2, "FILLED");
$num = -(count($array)+2);
$array = array_pad($array, $num, "FILLED");
print_r($array);
will return:
Array ( [0] => FILLED [1] => FILLED [2] => two [3] => three [4] => FILLED [5] =>
FILLED )
The ordering should be okay,...
--
http://www.php.net/manual/en/function.array-pad.php
http://master.php.net/manage/user-notes.php?action=edit+30609
http://master.php.net/manage/user-notes.php?action=delete+30609
http://master.php.net/manage/user-notes.php?action=reject+30609