count($temp[0]),
'title'=>$temp[1],
'link'=>$temp[2],
'desc'=>$temp[3]
);
}
/**********************************************************
* Parse Array data into an HTML structure *
* Usage: string parse_rss ( array data ) *
**********************************************************/
function output_rss($pattern, $rss_data, $count_latest) {
$temp = null;
for($i = 0; $i < $count_latest; $i++) {
$temp .= sprintf($pattern,
$rss_data['link'][$i],
html_entity_decode($rss_data['title'][$i]),
html_entity_decode($rss_data['desc'][$i])
);
}
return $temp;
}
/**********************************************************
* Settings *
**********************************************************/
$url = 'http://igeek.ru/feed';
$reg_exp = '#- .*?
(.*?)<\/title>.*?';
$reg_exp .='(.*?)<\/link>.*?';
$reg_exp .='(.*?)<\/description>.*?<\/item>#si';
$pattern = '%s
%s
'; /********************************************************** * Main script * **********************************************************/ if ( $xml_data = file_get_contents($url) ) { $rss_data = parse_rss($reg_exp, $xml_data); echo output_rss($pattern, $rss_data, 8); } /********************************************************** * The END * **********************************************************/
%s
'; /********************************************************** * Main script * **********************************************************/ if ( $xml_data = file_get_contents($url) ) { $rss_data = parse_rss($reg_exp, $xml_data); echo output_rss($pattern, $rss_data, 8); } /********************************************************** * The END * **********************************************************/