Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Turn local variable into a global variable


doubleJ - 3:30 pm on Sep 8, 2011 (gmt 0)


Hello...
I have this chunk of code...

<?php
$rss = new SimpleXMLElement("http://$fqdn/rss/FreeDownloads.xml", null, true);
foreach($rss->xpath("channel/item") as $item) {
$filename = basename($item->guid,".xml");
echo $filname;
}
?>

$filename seems to only be accessible within the foreach confines.
I'd like to be able to use the variable on other parts of the page.
I don't think I can move foreach to the top of the page or I'll be replicating a lot of code that I don't want replicated.
Any ideas?
JJ


Thread source:: http://www.webmasterworld.com/php/4360002.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com