Grabbing Values From an Array for Posting

Posted on 16th Feb 2014 by admin

I have a grid array that I am using with a form that when it hits the currently named test.php it logs in and grabs 3 coordinates (i.e. B1, D3, etc). which come back as XML fields "challenge1", "challenge2", and "challenge3" and then has to match up the value in the grid array and pass the correct value down to my post fields as "response1", "response2", "response3". However, nothing I'm trying will get the values out to then post. I'm sure my coding is wrong, but I cannot figure out the right syntax to make it work.

Here is part of my grid array:

$grid_array = array("A1" => "V", "A2" => "2", "A3" => "1", "A4" => "N", "A5" => "7", "B1" => "H", "B2" => "9", "B3" => "3", "B4" => "T", "B5" => "J", "C1" => "9", "C2" => "2", "C3" => "2", "C4" => "6", "C5" => "Y", "D1" => "N", "D2" => "1", "D3" => "R", "D4" => "8", "D5" => "K");

I tried coding this, which is completely wrong, but maybe I'm on to something at least?:

foreach ($grid_array as $key => $value) {
$grid_array['$xdoc1->challenge1'] = '$response1';
$grid_array['$xdoc1->challenge2'] = '$response2';
$grid_array['$xdoc1->challenge3'] = '$response3';
}

($xdoc1 is the XML return as a SimpleXMLElement, by the way)

But this returns an error of
Parse error: syntax error, unexpected T_DOUBLE_ARROW, expecting T_PAAMAYIM_NEKUDOTAYIM

Am I at least on the right track? If not, any ideas on how I can code this to pull out the values that are returned from the first hit and have it pass the appropriate values to the second hit?

Other forums