flamerail Posted May 21, 2006 Share Posted May 21, 2006 Im trying to generate a table with while then assign it to a var for later use. Is it possible?Also whats up with the phpfreaks chat? Its dead... is there an irc chat for us any where? Quote Link to comment https://forums.phpfreaks.com/topic/10091-can-you-assign-while-to-a-var/ Share on other sites More sharing options...
toplay Posted May 21, 2006 Share Posted May 21, 2006 I don't know why you'd really want to do that, however, any PHP can be assigned to a variable and executed at run time using eval().[a href=\"http://us2.php.net/manual/en/function.eval.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.eval.php[/a]I'll report the chat being down. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/10091-can-you-assign-while-to-a-var/#findComment-37536 Share on other sites More sharing options...
flamerail Posted May 21, 2006 Author Share Posted May 21, 2006 [!--quoteo(post=375613:date=May 20 2006, 09:01 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ May 20 2006, 09:01 PM) [snapback]375613[/snapback][/div][div class=\'quotemain\'][!--quotec--]I don't know why you'd really want to do that, however, any PHP can be assigned to a variable and executed at run time using eval().[a href=\"http://us2.php.net/manual/en/function.eval.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.eval.php[/a]I'll report the chat being down. Thanks.[/quote]That isnt doing quiet what I needed but thanks. Quote Link to comment https://forums.phpfreaks.com/topic/10091-can-you-assign-while-to-a-var/#findComment-37544 Share on other sites More sharing options...
.josh Posted May 21, 2006 Share Posted May 21, 2006 well if you are looking to do like, $blah = 'while';$x = 0;$blah ($x < 10) {...$x++;}the closest you are going to get is by using eval. Quote Link to comment https://forums.phpfreaks.com/topic/10091-can-you-assign-while-to-a-var/#findComment-37550 Share on other sites More sharing options...
jeremywesselman Posted May 21, 2006 Share Posted May 21, 2006 Why don't you put the code to generate the table into a function. Then you can call the function when you are ready to use the code in it.[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--] Quote Link to comment https://forums.phpfreaks.com/topic/10091-can-you-assign-while-to-a-var/#findComment-37553 Share on other sites More sharing options...
.josh Posted May 21, 2006 Share Posted May 21, 2006 oh wait, i get it. so you want to do something like this:[code]$x = 0;$blah = "<table>";while ($x < 10) { $blah.= "<tr><td>" . $x . "</td></tr>"; $x++;}$blah.="</table>";echo $blah;[/code]$blah is a string that holds the entire table and contents. Quote Link to comment https://forums.phpfreaks.com/topic/10091-can-you-assign-while-to-a-var/#findComment-37555 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.