array issue
am 27.11.2007 17:42:56 von Earl Clare------=_NextPart_000_0013_01C830E2.47CB7F40
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Guys really in need of some assistance here.
I am reading an xml file and want to loop through the entire file and
display the information.
Unfortunately I am only showing 1 item. how can I go about showing all news
item?
I've tried array and loop however I am not versed with any of them.
Thanks in advance
eg.
------------------------------------------------------------ -------------
------------------------------------------------------------ -------------
My current code
+++++++++++++++++++++++++++++++++
function getNews()
{
$file = NEWS_FILE.".xml";
if(!file_exists($file) || filemtime($file) <
time() - 43200) {
$this->data =
@file_get_contents("http://feeds.mydomain.com/dailynews");
$fp = @fopen($file, 'w');
@fwrite($fp, $this->data);
@fclose($fd);
}
else $this->data =
@file_get_contents($file);
if(strlen($this->data) <= 0) return;
// get the location
$attr = explode('<', $this->tag('item'));
$return['title'] = $attr[1];
$return['title'] = substr($return['title'],
6);
$return['description'] = $attr[7];
$return['description'] =
substr($return['description'], 2);
return $return;
}
function view_news()
{
$currentNews = newsfeed::getNews();
$NEWS=
''.$currentNews['title'].'
'.$currentNews['description']
...'
';
return $NEWS;
}
function tag($tag, $skip=0)
{
$start = -1;
for($i = 0; $i <= $skip; $i++)
$start = strpos($this->data,
"<{$tag}", $start + 1);
if($start === false) return false;
$start += strlen($tag) + 1;
$end = strpos($this->data, "{$tag}>",
$start);
if($end === false)
$end = strpos($this->data,
'/>', $start);
return trim(substr($this->data, $start, $end
- $start));
}
------=_NextPart_000_0013_01C830E2.47CB7F40--