troubleshooting Question

Organize data from Google news API using php

Avatar of Pedro Chagas
Pedro ChagasFlag for Portugal asked on
3 Comments2 Solutions520 ViewsLast Modified:
Hi E's, I need to organize some data from a query of google news API, and I want to list or organize and put some of that received information into a php array. In this case I want put the publishers of the news into array.
I try this code:
$jsonString = file_get_contents("");
$json = json_decode($jsonString);
$links = array();
foreach($json->foo as $item) {
  $links[] = $item->publisher;
But the result is:
Warning: Invalid argument supplied for foreach() in /home/pedro/public_html/biblioteca/tutoriais/1140/exemplo.php on line 5

What I do wrong?

The best regards, JC
John Kawakami

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros