Mark
Mark

Reputation: 41

php array in array foreach

I have the folowing code:

foreach($itz as $vz) { 
$muAt_val = $browser->getFieldByName($vz);
array_push_assoc($mAtArray, $vz, $mAt_val);              
} 

Which outputs:

[mAt[1701]] => Array ( [0] => 9378 [1] => 9379 )

But I would like to have it:

[mAt[1701]] => 9378 [mAt[1701]] => 9379

How can I do this?

//update A duplicate index of an array is not possible, i'm using an array for saving an form

 $browser->post($url, $parameters); // $parameters = the array

When I save the form by hand I get a post(firebug) with:

 mAt[1701] = 9378 
 mAt[1701] = 9379

This is not possible with an array, how can I make this work?

Thanks,

Upvotes: 0

Views: 98

Answers (1)

AwokeKnowing
AwokeKnowing

Reputation: 8206

don't use push, use

foreach($itz as $vz) { 
   $muAt_val = $browser->getFieldByName($vz);
   $mAtArray[$vz]= $mAt_val;              
} 

Upvotes: 1

Related Questions