Search the Community
Showing results for tags 'rss parser php'.
-
Hello, I am new here. I am using WordPress, and I want to show 5 items from Search Engine (bing), related to my blog content. I want to change "This+Is+Search+Keyword" with my post title ($title or the_title()), so every single post in my blog will have 5 related bing results. Here the code I am using. Can somebody help me? <?php function DisplayTitle($title){ $title = the_title(); //this is my post title// $title = str_replace(' ', '+', $title); return ($title); } $FixTitle = DisplayTitle($title); $rss = new DOMDocument(); $rss->load('http://www.bing.com/search?q=This+Is+Search+Keyword&format=RSS'); // <<<<<< I want to change "this is keyword" with "my post title"// $feed = array(); foreach ($rss->getElementsByTagName('item') as $node) { $item = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue, ); array_push($feed, $item); } $limit = 5; for($x=0;$x<$limit;$x++) { $title = str_replace(' & ', ' & ', $feed[$x]['title']); $link = $feed[$x]['link']; $description = $feed[$x]['desc']; $date = date('l F d, Y', strtotime($feed[$x]['date'])); echo '<p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />'; echo '<small><em>Posted on '.$date.'</em></small></p>'; echo '<p>'.$description.'</p>'; } ?>