RE: [PHP] evaluating dynamic variable

From: Date: Tue, 02 Sep 2003 20:44:25 +0000
Subject: RE: [PHP] evaluating dynamic variable
Groups: php.general 
Request: Send a blank email to php-general+get-161483@lists.php.net to get a copy of this message
When I run the code you've attached, with $i iterating up to 3, I get three 'empty!', even if $resolution1 should be 'not empty!'. It seems like the $i in $_POST["resolutions".$i] is not getting parsed into a value, and php is looking for a key resolutions$i. Whoops, I'm an idiot. Resolution singular, not plural. Thanks for the help everyone . -----Original Message----- From: Chris W. Parker [mailto:cparker@swatgear.com] Sent: Tuesday, September 02, 2003 3:29 PM To: Stephen Goodman; php-general@lists.php.net Subject: RE: [PHP] evaluating dynamic variable Steve Goodman <mailto:sgoodman@immunetolerance.org> on Tuesday, September 02, 2003 12:54 PM said: > Can someone > recommend a way to reliably evaluate this variable? 1. (not positive on this point so correct me if I'm wrong) you shouldn't compare with !==. Instead us !=. 2. What does the following do? for ($i=1; $i<=$entries; $i++) { if(empty($_POST["resolutions".$i])) { echo "empty!"; } else { echo "not empty!" } } You might also like to try isset() along with empty(). hth, Chris.

« previous php.general (#161483) next »