The code below extracts <TITLE> and <LINK> elements from a standard rss-type xml file (<ITEM><TITLE><LINK><DESCRIPTION></ITEM>).
I am uncertain how this works. I see how ereg is used to parse each line for an instance of the <TITLE> tag and then passes it into $title. How is <LINK> assembled into the array? How could I pass <DESCRIPTION> into the array as well?
$startat = "</image>";
$linkstr = "link";
$exclude = "";
$startnum = 0;
// determine which line to begin grabbing the links
for ($i=0;$i<count($lines);$i++) {
if (ereg($startat,$lines[$i],$regs)) {
$startnum = $i;
break;
}
}
// extract the links and assemble into array $links
$links = array();
for ($i=$startnum;$i<count($lines);$i++) {
if (count($links)>=$this->listings) break;
if (ereg("<title>(.*)</title>",$lines[$i],$regs)) {
if ($regs[1] == $exclude) {$i+=1; break;}
$title = $regs[1];
$title = ereg_replace("&apos;","'",$title);
}
else if (ereg("<$linkstr>(.*)</$linkstr>",$lines[$i],$regs)) {
$links[$title] = $regs[1];
}
}
return $links;