Frage

I'm using the recent tickets JSON feed in Zendesk with the following line of PHP:

$data = curlWrap("/tickets/recent.json", null, "GET");

When I use a foreach function as below, I get the error message "Invalid argument supplied for foreach()".

foreach ( $data->tickets as $ticket )

What am I doing wrong?

War es hilfreich?

Lösung

It needs to be an array. You can use the json_decode() to turn it into an array, eg

$json = curlWrap("/tickets/recent.json", null, "GET");
$data = json_decode($data);

And then you can proceed with the foreach array.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top