note 49804 added to function.eval
| From: | avenger at buynet dot com dot br | Date: | Wed, 09 Feb 2005 04:52:27 +0000 |
| Subject: | note 49804 added to function.eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-84700@lists.php.net to get a copy of this message | ||
This is a small code that uses 'eval' with a foreach (maybe 'for' loop), to fill
variables. This is very useful in some hard situations:
<html><title>for loop</title><body><p align=center>
<?php
$thing = array("a","b","c");
$a = "bah" ; $b = "bleh2"; $c = "bluh3";
print("Vars b4: $a, $b, $c. ");
foreach ( $thing as $thingy ) {
print("$thingy, ");
eval("\$$thingy = \"$thingy\";");
};
print("vars aft: $a, $b, $c.");
?>
</p></body></html>
----
Manual Page -- http://www.php.net/manual/en/function.eval.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49804
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49804&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49804&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49804&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49804&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49804&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49804&report=yes
Search -- http://master.php.net/manage/user-notes.php