From: "Geoff Caplan" <[EMAIL PROTECTED]>
Getting a result I don't understand.

Why does the non-existent key in the array below evaluate to the
first char of the array value?

$foo = '' ;
$foo['one']['two'] = 'test-value' ;

// Evaluates to: string(1) "t"
var_dump( $foo['one']['two']['three'] ) ;


// Evaluates to NULL, as expected var_dump($foo['one']['two']['three']['four'] ) ;

Can anyone enlighten me?

Strings are arrays. PHP probably takes the string 'three' and converts it to a integer to see what "key" of the string you're requesting.


$foo = 'bar';
echo $foo[1]; //should echo 'a'

Does that help or do you need a deeper explanation (that I probably can't provide!) ;)

---John Holmes...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to