Syntax not allowed

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-26-2006
Bob Stearns
 
Posts: n/a
Default 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
Reply With Quote
  #2 (permalink)  
Old 02-26-2006
Chung Leong
 
Posts: n/a
Default Re: Syntax not allowed

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

Reply With Quote
  #3 (permalink)  
Old 02-26-2006
Manifest Interactive
 
Posts: n/a
Default Re: Syntax not allowed

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

Reply With Quote
  #4 (permalink)  
Old 02-27-2006
Tim Roberts
 
Posts: n/a
Default Re: Syntax not allowed

"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.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:01 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0