This is a discussion on Syntax not allowed within the PHP Language forums, part of the PHP Programming Forums category; The following is not allowed (simplified for this forum): but it seems reasonable to me. Could some one explain mw ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
The following is not allowed (simplified for this forum): but it seems
reasonable to me. Could some one explain mw lack of insight? $t = (array(1=>"Sold", 3=>"Transit"))[$location_id]; Parse error: parse error, unexpected '[' in /var/www/html/GEM-is/batchJobs/sales.php on line 183 |
|
|||
|
Greetings,
This is the standard syntax to build a PHP array: $myArray = array('index1' => 'val1', 'index2' => 'val2', 'index3' => 'val3'); To create a multidimensional array you could use something like this: $myArray = array("A" => array("a", "b", "c" => array("x")), "B" => "y"); Not sure if this is close to what you are looking for - Peter Schmalfeldt Manifest Interactive |
|
|||
|
"Manifest Interactive" <manifestinteractive@gmail.com> wrote:
>Greetings, > >This is the standard syntax to build a PHP array: > >$myArray = array('index1' => 'val1', 'index2' => 'val2', 'index3' => >'val3'); > >To create a multidimensional array you could use something like this: > >$myArray = array("A" => array("a", "b", "c" => array("x")), "B" => >"y"); > >Not sure if this is close to what you are looking for Not at all. He was trying to create a temporary array and reference an element of it without saving to a variable. I, also, am surprised this doesn't work. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. |