RE: [PHP] evaluating dynamic variable

From: Date: Tue, 02 Sep 2003 20:24:56 +0000
Subject: RE: [PHP] evaluating dynamic variable
Groups: php.general 
Request: Send a blank email to php-general+get-161477@lists.php.net to get a copy of this message
[snip] I'm having trouble evaluating a dynamic variable. I want to check if the variable $_POST["resolutions$i"] is an empty string, as you'll see from the code. However, every way I've tried to check the variable so far (including empty() and eval()) always returns a null value, even when the variable should contain a value. I've probably been doing something wrong in my previous efforts. Can someone recommend a way to reliably evaluate this variable? for ($i=1; $i<=$entries; $i++) { if($_POST["resolutions$i"] !== ''){ do_something(); } } [/snip] Well, I tried this /* ** submit form (res1.php) */ <form action="res2.php" method="POST"> <input type="text" name="resolution1"> <input type="text" name="resolution2"> <input type="submit"> </form> /* ** process (res2.php) */ <?php $entries = count($_POST); for ($i=1; $i<=$entries; $i++) { if($_POST["resolutions$i"] !== ''){ print($_POST["resolution$i"]); } } ?> And I had no problems. HTH!

« previous php.general (#161477) next »