0

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,

3
  • 2
    The expected output is unclear. Could you elaborate a little? Commented Oct 30, 2013 at 17:48
  • Your third code block isn't a valid array structure. If you just want it to print out in that format, it should be easy to do that. Commented Oct 30, 2013 at 17:50
  • I use the Simpletest browser to fill a form and save it. the form has multiselect which is mAt. The multiselect has all the same name "1701" but different value's "9379 & 9378". When saving the form I use $browser->post('url.html', $array); I'm a bit stuck now on how to format the multiselect array. Commented Oct 30, 2013 at 19:14

1 Answer 1

1

don't use push, use

foreach($itz as $vz) { 
   $muAt_val = $browser->getFieldByName($vz);
   $mAtArray[$vz]= $mAt_val;              
} 
Sign up to request clarification or add additional context in comments.

1 Comment

function array_push_assoc does this, custom function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.