|
Posted by Marcin 'frodo2000' Molak on 08/06/07 14:04
On 6 Sie, 15:54, zebul0n <zebu...@free.fr> wrote:
> Hello,
>
> I have an array :
>
> Array ( '2' => '27584.10', '3' => '1008.00', '6' => 11393.55, '7' => 888.12 )
>
> which i need to modify to fill missing keys from 0 to 11 with zero
> value. Like this :
>
> Array ( '0' => '0', '1' => '0', '2' => '27584.10', '3' => 1008.00', '4' =>
> '0', '5' => '0', '6' => '11393.55', '7' => '888.12', '8' => '0', '9' =>
> '0', '10' => '0', '11' => '0' )
>
> but I couldn't find an array function to fill the missing keys with a zero
> value.
>
> Thank you.
Maybe, you should try prepare own function, for example:
$array = array('2' => '27584.10', '3' => '1008.00', '6' => 11393.55,
'7' => 888.12);
for ($i=0; $i<12; $i++){
if (!array_key_exists($i)) $array[$i] = 0;
}
Regards,
Marcin
Navigation:
[Reply to this message]
|