note 53960 added to function.eval

From: Date: Sat, 18 Jun 2005 20:25:24 +0000
Subject: note 53960 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-90633@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.eval.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+53960 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53960&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53960&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53960&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53960&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+53960&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53960&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+53960&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90633) next »