php - How to turn variable feed to array? -
i want turn variable array can store more 1 feed?
<?php error_reporting(0); $feed_lifehacker_full = simplexml_load_file('http://feeds.gawker.com/lifehacker/full'); $xml = $feed_lifehacker_full; //print_r($xml); foreach ($xml->channel->item $node){ $title = $node->title; $link = $node->link; $link = explode('/', $link); $link = $link[8]; $url = $node->url; $description = $node->description; $pubdate = $node->pubdate; preg_match_all('#(http://img[^\s]+(?=\.(jpe?g|png|gif)))#i', $description[0], $images); $images = $images[0][1] . '.jpg'; if($images == '.jpg'){ //uncomment show youtube articles //$images = "http://placehold.it/640x360"; //echo "<a href='page2.php?a=$link' title='$title'><img src='$images' /></a><br>"; } else { //article image $images . '<br>'; echo "<a href='page2.php?a=$link' title='$title'><img src='$images' /></a><br>"; } }
how can change load arrays,
$feed_lifehacker_full = simplexml_load_file('http://feeds.gawker.com/lifehacker/full'); $xml = $feed_lifehacker_full;
the script gathering image of rss feed , linking page, if see how can done more efficiently feel free say
it possible encode result given json , decoding it return array
$xml = simplexml_load_string($xmlstring); $json = json_encode($xml); $array = json_decode($json, true);
Comments
Post a Comment