Syntax not allowed

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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

Re: Syntax not allowed

The parser can't handle such syntax, that's all.

Re: Syntax not allowed


This is the standard syntax to build a PHP array:

$myArray = array('index1' => 'val1', 'index2' => 'val2', 'index3' =>

To create a multidimensional array you could use something like this:

$myArray = array("A" => array("a", "b", "c" => array("x")), "B" =>

Not sure if this is close to what you are looking for

- Peter Schmalfeldt
Manifest Interactive

Re: Syntax not allowed

Quoted text here. Click to load it

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,
  Providenza & Boekelheide, Inc.

Site Timeline