In PHP, how can I return JSON elements values in a string separated by commas?
This is how I'm calling the "list" JSON file in PHP:
$list = file_get_contents('http://example.com/list/json');
$items = json_decode($list, true);
This is the List JSON content (may contain more items, and more columns for each, not only itemID):
{
"resultCount":3,
"results": [
{"itemId":1223604159},
{"itemId":1231618623},
{"itemId":1244303880}]
}
So I want this string as response:
1223604159,1231618623,1244303880
Already tried implode without success:
$IdByCommas = implode(',',$items->results->itemId);