note 50912 added to language.variables.variable
| From: | Anonymous at osu1 dot php dot net | Date: | Mon, 14 Mar 2005 03:25:25 +0000 |
| Subject: | note 50912 added to language.variables.variable | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86378@lists.php.net to get a copy of this message | ||
It may be worth specifically noting, if variable names follow some kind of "template,"
they can be referenced like this:
<?php
// Given these variables ...
$nameTypes = array("first", "last", "company");
$name_first = "John";
$name_last = "Doe";
$name_company = "PHP.net";
// Then this loop is ...
foreach($nameTypes as $type)
print ${"name_$type"} . "\n";
// ... equivalent to this print statement.
print "$name_first\n$name_last\n$name_company\n";
?>
This is apparent from the notes others have left, but is not explicitly stated.
----
Manual Page -- http://www.php.net/manual/en/language.variables.variable.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50912
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50912&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50912&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50912&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50912&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50912&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50912&report=yes
Search -- http://master.php.net/manage/user-notes.php