470,832 Members | 2,079 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,832 developers. It's quick & easy.

Syntax not allowed

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
Feb 26 '06 #1
3 1225
The parser can't handle such syntax, that's all.

Feb 26 '06 #2
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

Feb 26 '06 #3
"Manifest Interactive" <ma*****************@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, ti**@probo.com
Providenza & Boekelheide, Inc.
Feb 27 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Dave | last post: by
8 posts views Thread by Ike | last post: by
19 posts views Thread by Nicolas Fleury | last post: by
6 posts views Thread by =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post: by
14 posts views Thread by paresh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.