Jump to content

syntax problem


felito

Recommended Posts

I doubt seriously this is the best way to handle whatever it is that you are trying to do, however it can be accomplished.

 

$i=0;
while ($sql -> fetch()) {
                         $name = 'num' . $i++;
		 $$name = $form[$val]; 			 
}

// now you'll have variables $num0... x

for ($x = 0; $x   echo '$num'.$x . ' = ' .  ${'num'.$x} . '
';
}

 

 

Link to comment
https://forums.phpfreaks.com/topic/239183-syntax-problem/#findComment-1229403
Share on other sites

Don't ever use variable variables unless you're absolutely certain there's no other way to go about doing things.  If you ever have variables with sequential numbers at the end, you've done it wrong.  The Array construct is perfect for what you're trying to do.

 

-Dan

Link to comment
https://forums.phpfreaks.com/topic/239183-syntax-problem/#findComment-1230038
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.