note 74357 added to language.variables
| From: | zaitsman at mail dot ru | Date: | Sat, 07 Apr 2007 10:04:21 +0000 |
| Subject: | note 74357 added to language.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125163@lists.php.net to get a copy of this message | ||
Spent about an hour figuring this out - if you have an array and wanna get to its content using
another variable as its cell name you should do like this:
<?php
$_SAMPLE_ARRAY['something_1']=123;
$_SAMPLE_ARRAY['something_2']=321;
$id=1;
echo $_SAMPLE_ARRAY{"something_".$id};
//will output 123
?>
----
Server IP: 69.147.83.197
Probable Submitter: 81.200.119.187
----
Manual Page -- http://www.php.net/manual/en/language.variables.php
Edit -- https://master.php.net/note/edit/74357
Del: integrated -- https://master.php.net/note/delete/74357/integrated
Del: useless -- https://master.php.net/note/delete/74357/useless
Del: bad code -- https://master.php.net/note/delete/74357/bad+code
Del: spam -- https://master.php.net/note/delete/74357/spam
Del: non-english -- https://master.php.net/note/delete/74357/non-english
Del: in docs -- https://master.php.net/note/delete/74357/in+docs
Del: other reasons-- https://master.php.net/note/delete/74357
Reject -- https://master.php.net/note/reject/74357
Search -- https://master.php.net/manage/user-notes.php