note 49804 deleted from function.eval by peehaa

From: Date: Mon, 09 Dec 2013 11:52:26 +0000
Subject: note 49804 deleted from function.eval by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197850@lists.php.net to get a copy of this message
Note Submitter: avenger at buynet dot com dot br ---- 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>

« previous php.notes (#197850) next »