php - Array to String Conversion Error while tweaking Simplepie -


i using simplepie library feed generation. made changes desired output. working great till today. here code:

<?php header('content-type: text/plain; charset=utf-8');  // include simplepie library // 1.0-1.2: #require_once('simplepie.inc'); // 1.3+: require_once('autoloader.php');  // create new simplepie object $feed = new simplepie();  // instead of passing in 1 feed url, we'll pass in array of 3 $feed->set_feed_url(array(  'http://localhost/full-text-rss/makefulltextfeed.php?url=dynamic.feedsportal.com%2fpf%2f555218%2fhttp%3a%2f%2ftoi.timesofindia.indiatimes.com%2frssfeedstopstories.cms&key=1&hash=759dbac5d2121d4b7bc31ee9119d65a44a73fb6d&max=10&links=preserve&exc=1&format=json'  )); //caching enabled $feed->enable_cache(true);  //timeout $feed->set_timeout(40);  // we'll use favicon caching here (optional) //$feed->set_favicon_handler('handler_image.php');  // initialize feed object $feed->init();  // work if of feeds accept same settings. $feed->handle_content_type();     if ($feed->error)  {   echo $feed->error;   }   $newspapername = array('google news');     $i = 0;  $j = 0;  $response = array();   $response["newsitems"] = array();   foreach ($feed->get_items() $item)  {           $feed = $item->get_feed();          //$permalink =         //$newsitems["count"] = html_entity_decode($feed,ent_quotes, "utf-8");//html_entity_decode($item->get_id(),ent_quotes, "utf-8");            $newsitems["articlelink"] = html_entity_decode($item->get_permalink(),ent_quotes, "utf-8");//$permalink;          $newsitems["title"] = html_entity_decode($item->get_title(), ent_xhtml, "utf-8");           $newsitems["content"]= html_entity_decode($item->get_content(), ent_xhtml, "utf-8");          if($i==10)         {           $i = 0;          $newsitems["source"] = html_entity_decode($newspapername[$j+1],ent_quotes, "utf-8");          $j++;         }         else         {           $newsitems["source"] = html_entity_decode($newspapername[$j],ent_quotes, "utf-8");;          $i++;         }          $feed = $item->get_feed();           $newsitems["sourcelink"]= html_entity_decode($feed->get_permalink(), ent_xhtml, "utf-8");          $feed = $item->get_feed();           $newsitems["sourcetitle"] =       html_entity_decode($feed->get_title(), ent_xhtml, "utf-8");          $newsitems["date"]= html_entity_decode($item->get_date('j m y |   g:i t'), ent_xhtml, "utf-8");          array_push($response["newsitems"], $newsitems);  } echo json_encode($response); ?> 

but today got error:

notice: array string conversion in c:\xampp\htdocs\simplepie\indiaenglishtopstories.php on line 38 array{"newsitems":[]}  

line 38 is:

echo $feed->error; 

i not php developer knowledge limited. read many answer here , tried implement still problem there. forgive me if find question stupid , annoying. thank time.

your trying echo array not possible. $feed->error array.

change

foreach($feed->error $err)   echo $err; 

or

var_dump($feed->error) 

or

print_r($feed->error) 

php echo array


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -