note 38042 deleted from language.types.array by tomsommer
| From: | tomsommer@php.net | Date: | Sat, 03 Jul 2004 13:20:28 +0000 |
| Subject: | note 38042 deleted from language.types.array by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72420@lists.php.net to get a copy of this message | ||
Note Submitter: kieran@kieran.ca
----
I ran across something that should be noted...
Take care when using variables for referencing arrays. PHP will interpret the square bracket syntax
[] as a substr() like reference....
<?
// this doesn't work, PHP evaluates $($foo[$bar]) instead of ($$foo)[$bar]
$temp = $$foo[$bar];
/*--------------------------------------------------------*/
// use this method instead:
// make a temp array so we can refer to it by an absolute name
$temp_array = $$foo;
// now pull the value
$temp = $temp_array[$bar];
?>
Cheers!
Kieran