note 50319 added to function.eval

From: Date: Thu, 24 Feb 2005 15:51:46 +0000
Subject: note 50319 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-85494@lists.php.net to get a copy of this message
I couldn't find an example of what I wanted to do, which was dynamically create and handle enumerated variables from a form, so here it is in simplified form: <?php echo("<table>"); $counter=0; for ($a=0;$a<count($timeslots);$a++) { echo("<tr>"); for ($i=0;$i<3;$i++) { $counter++; $fieldwithcounter="fieldname$counter"; $var1=$_POST[$fieldwithcounter]; $nextfield="second$counter"; $var2=$_POST[$nextfield]; $thirdfield="lastfield$counter"; $var3=$_POST[$thirdfield]; eval("\$grouprow$a.=\"$var1^^$var2^^$var3^^$var4\";"); // creates $grouprow0, $grouprow1, $grouprow2, ... echo("<td> First field <input type='text' name='fieldname$counter' value='$var1'><br> Second field <input type='text' name='second$counter' value='$var2'><br> Last field <input type='text' name='lastfield$counter' value='$var3'> </td>"); } echo("</tr>"); } echo("</table>"); ?> ---- Manual Page -- http://www.php.net/manual/en/function.eval.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50319 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50319&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50319&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50319&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50319&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50319&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50319&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85494) next »