note 53960 deleted from function.eval by peehaa
| From: | peehaa@php.net | Date: | Mon, 09 Dec 2013 11:57:28 +0000 |
| Subject: | note 53960 deleted from function.eval by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197858@lists.php.net to get a copy of this message | ||
Note Submitter: Jesse
----
a cool way to use eval is to convert strings into variable names.
this is a subsitute for using arrays.
look at this code:
<?php
for($a=1; $a<=5; $a++){
eval("$"."variable".$a."=".$a.";");
}
?>
this will create variables called variable1, variable2, and so on, that are equal to 1, 2, and so
on.
i recently used this to help a friend make a Flash game that sent variables like that to PHP.