Wednesday, August 24, 2011

Function to Convert RSS to Array using PHP from RSS URL

Working with RSS feed is more usefull to promote your website as well as you can get relevant content for your website from another website using RSS Feed, Let us write a code  how to to get RSS feed content from RSS URL.

Function to Create RSS Details to PHP Array 


function rss_to_array($tag, $array, $url) {
	$doc = new DOMdocument();
	$rss_array = array();
	$items = array();
	foreach($doc->getElementsByTagName($tag) AS $node) {    
			foreach($array AS $key => $value) {
					$items[$value] = $node->getElementsByTagName($value)->item(0)->nodeValue;
			array_push($rss_array, $items);
	return $rss_array;

        $rss_tags = array(
        $rss_item_tag = 'item';
        $rss_url = '';
        $rssfeed = rss_to_array($rss_item_tag,$rss_tags,$rss_url);
echo '<pre>';


No comments:

Post a Comment