putting the results of a function into a variable
Posted: Wed Feb 28, 2007 7:08 pm
I want to put the outputs of an include function that is in a basic "fetch while there are still rows" while loop into a variable.
ex.
and the contents of post.inc are
And say that there were three rows, so the product of this while loop would be
I want to put all of those into a variable, so that
Is it possible to do this?
I'm kinda thinking this:
But I don't think it will work because PHP will interpret it as me wanting to define an anonymous function in $variable. Am I correct or am I just crazy?
Any help you can give is very appreciated ^_^
-alecks
ex.
Code: Select all
while ($result = mysql_fetch_array($query)){
include("post.inc");
}Code: Select all
<h1><?php print $result['row_that_was_fetched']; ?></h1>Code: Select all
<h1><?php print $result['row_that_was_fetched']; ?></h1><h1><?php print $result['row_that_was_fetched']; ?></h1><h1><?php print $result['row_that_was_fetched']; ?></h1>Code: Select all
$variable = <h1><?php print $result['row_that_was_fetched']; ?></h1><h1><?php print $result['row_that_was_fetched']; ?></h1><h1><?php print $result['row_that_was_fetched']; ?></h1>I'm kinda thinking this:
Code: Select all
while ($result = mysql_fetch_array($query)){
$variable .= include("post.inc");
}Any help you can give is very appreciated ^_^
-alecks