On Tue, Aug 21, 2012 at 12:01 AM, <s....@optusnet.com.au> wrote: > Hi, this is my first post so forgive me if I missed a rule and do something > wrong. > > I have this code, > > echo $_SERVER['PHP_SELF']."?"; > foreach ($_GET as $urlvar=>$urlval) > echo $urlvar."=".$urlval."&"; > > It works by it’s self. > I want to insert the output in a table. Is there a way to ‘echo’ into a > variable(i.e. make the output of this echo the value of a variable) or am I > on the wrong track all together?
This question actually belongs on the PHP General mailing list. As for echoing into a variable, the only way that's really possible is with output buffering (ob_start(), ob_get_contents(), ob_end_clean(), et al). However, you don't need (and shouldn't want) to do this here. Instead, as your snippet really won't do much of anything useful, you should (entirely) rewrite your code to look something like this, for an HTML table: <?php echo $_SERVER['PHP_SELF'].'?'.PHP_EOL; echo '<table>'.PHP_EOL; foreach ($_GET as $key => $value) { echo ' <tr>'.PHP_EOL; echo ' <td>'.$key.'</td>'.PHP_EOL; echo ' <td>'.$value.'</td>'.PHP_EOL; echo ' </tr>'.PHP_EOL; } echo '</table>'; ?> However, since it looks almost as if you're trying to build a query string based upon the supplied GET variables, you may want to try looking into http_build_query(). -- </Daniel P. Brown> Network Infrastructure Manager http://www.php.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php