RE: [PHP-WIN] Print inside a variable
| From: | Wu, Jin Yong | Date: | Sun, 08 May 2005 02:46:17 +0000 |
| Subject: | RE: [PHP-WIN] Print inside a variable | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-25982@lists.php.net to get a copy of this message | ||
I am not sure whether you want to get the executing result of such PHP
script into the variable $message or not ???
If so, you can use output buffer.
<?php
ob_start();
/* the following is the snippet you gave */
if (isset($rss_channel["ITEMS"])) {
if (count($rss_channel["ITEMS"]) > 0) {
..........
print ("<b>There are no articles in this feed.</b>");
}
}
$message = ob_get_contents();
?>
Regards,
Yong from Xerox, China
2005/5/8
-----Original Message-----
From: Maxwell Brodie [mailto:max.b@shaw.ca]
Sent: Tuesday, May 03, 2005 11:35 AM
To: php-windows@lists.php.net
Subject: [PHP-WIN] Print inside a variable
Hello,
I believe my problem is that I have to use the print funtion inside a
variable, and I have no clue how to do that. For example, I need to get
this:
if (isset($rss_channel["ITEMS"])) {
if (count($rss_channel["ITEMS"]) > 0) {
for($i = 0;$i < count($rss_channel["ITEMS"]);$i++) {
if (isset($rss_channel["ITEMS"][$i]["LINK"])) {
print ("\n<div class=\"itemtitle\"><a href=\"" .
$rss_channel["ITEMS"][$i]["LINK"] . "\">" .
$rss_channel["ITEMS"][$i]["TITLE"] . "</a></div>");
} else {
print ("\n<div class=\"itemtitle\">" .
$rss_channel["ITEMS"][$i]["TITLE"]
. "</div>");
}
print ("<div class=\"itemdescription\">" .
$rss_channel["ITEMS"][$i]["DESCRIPTION"] . "</div><br
/>"); }
} else {
print ("<b>There are no articles in this feed.</b>");
}
}
Into variable "$message="
Any help would be appriciated MUCH!
Thank you!
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php