Page 1 of 1

Syntax Error: unexpected T_DOUBLE_ARROW (2 demnsional array)

Posted: Thu Jul 02, 2009 2:35 pm
by mmX
For the life of me I don't know what I did wrong here, it seems so straight forward.

(yeah, I'm new to PHP...)
I get the unexpected T_DOUBLE_ARROW on the line with index number 6, the first nested array. What am I doing wrong here?

Code: Select all

$type = array(0 => "No Input",                                                  
    1 => "No Input",                                                            
    2 => "No Input",                                                            
    3 => "No Input",                                                            
    4 => "No Input",                                                            
    5 => "Y/N Select",                                                      
    6 => "Select" => array(0 => "No Data", 1 => "Age Exempt", 2 => "1 MMR", 3 => "2 MMR", 4 => "Immune"),
    7 => "Select" => array(0 => "No Data", 1 => "Vaccinated", 2 => "Responder", 3 => "Declined", 4 => "Opt Out"),
    8 => "Select" => array(0 => "No Data", 1 => "Contraindication"),
    9 => "Date",                                                                
    10 => "Select" => array(0 => "No Data", 1 => "Immune by Disease", 2 => "Immune by Vaccine"),
    11 => "Select" => array(0 => "No Data", 1 => "Annual Skin Test", 2 => "Reactor"),
    12 => "Date",                                                               
    13 => "Select" => array(0 => "No Data", 1 => "Given", 2 => "Contraindication", 3 => "Declined"),
    14 => "Date",                                                               
);   

Re: Syntax Error: unexpected T_DOUBLE_ARROW

Posted: Thu Jul 02, 2009 2:41 pm
by BornForCode
This is wrong: 6 => "Select" => array(0

Proper is: 6=>array("Select" => array())

Re: Syntax Error: unexpected T_DOUBLE_ARROW

Posted: Thu Jul 02, 2009 2:50 pm
by mmX
That doesn't make it a 3 dimensional array as opposed to a 2 dimensional?

edit:
It seems to have?
This code works for everything but "Select" now...

Code: Select all

switch ($type[$x]) {
    case "No Input":
        // do stuff
    case "Select":
        // do stuff
    case "Y/N Select":
        // do stuff
    case "Date":
        // do stuff
}

Re: Syntax Error: unexpected T_DOUBLE_ARROW (2 demnsional array)

Posted: Thu Jul 02, 2009 5:45 pm
by mmX
so, here's the output of that array:

Code: Select all

Array ( [0] => No Input [1] => No Input [2] => No Input [3] => No Input [4] => No Input [5] => Y/N Select [6] => Array ( [Select] => Array ( [0] => No Data [1] => Age Exempt [2] => 1 MMR [3] => 2 MMR [4] => Immune ) ) [7] => Array ( [Select] => Array ( [0] => No Data [1] => Vaccinated [2] => Responder [3] => Declined [4] => Opt Out ) ) [8] => Array ( [Select] => Array ( [0] => No Data [1] => Contraindication ) ) [9] => Date [10] => Array ( [Select] => Array ( [0] => No Data [1] => Immune by Disease [2] => Immune by Vaccine ) ) [11] => Array ( [Select] => Array ( [0] => No Data [1] => Annual Skin Test [2] => Reactor ) ) [12] => Date [13] => Array ( [Select] => Array ( [0] => No Data [1] => Given [2] => Contraindication [3] => Declined ) ) [14] => Date )
Here:
[6] => Array ( [Select] => Array ( [0] => No Data
I see an array being saved to position 6, said array is holding another array that actually contains the values...

Is this the only way it works in PHP; because, that is definitely not the desired result.