Tony Stark Tony Stark - 1 year ago 88
PHP Question

JSON/cURL - Trying to decode results from GET request

Here is my code


$url = "";
// Initiate curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIE, "ChosenSite=www; SportsDirect_AnonymousUserCurrency=GBP; language=en-GB");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20080311 Firefox/');
curl_setopt($ch, CURLOPT_VERBOSE, true);
// Execute
// Closing

// Will dump a beauty json :3
$collections = json_decode($result);

foreach ($collections as $item) {
$Title = $item->Products->Title;

echo $Title;

With this code i receive blank screen, no results are printed.
All i want is to
all the
names of all products.

Where is my mistake, how can i achieve what i want ?

Answer Source

Use Below code. It will help you definatly.

foreach ($collections as $row){
foreach ($row->Products as $item) {
    $Title = $item->Title;            

    echo $Title;


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download