ID:               15378
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           Open
 Bug Type:         Arrays related
 Operating System: Linux 2.4, Apache 1.3.22
 PHP Version:      4.1.1
 New Comment:

I should add that the the first level of the array works fine, it is
just the second (& following) levels that cannot be used.

<?php

// This works:
$var[name] = 'Caleb';
echo "I am $var[name]";

// This does not:
$var[name][first] = 'caleb';
echo "I am $var[name][first]";


Previous Comments:
------------------------------------------------------------------------

[2002-02-05 00:30:39] [EMAIL PROTECTED]

<?php

$var = array(
    'name' => array(
        'first' => 'Caleb',
        'last' => 'Maclennan'
      )
  );

echo "My first name is $var[name][first]!";

?>

Acutal Result:
My first name is Array[first]!

Correct Result:
My first name is Caleb!

This get's really nasty when useing 3 dimentional arrays to put data in
SQL querys. The above example can easily be done by takeing the
variable out of the quotes and useing "." to add it to the end, but
there are other cases where the only solution is to do like this:

<?php
$tempVar = $var[name][first];
echo "My name is $tempVar";
?>


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=15378&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to