Retrive multiple values from single dimension value / key JSON
- by jonnypixel
I'm busting my head trying to work this out.
"ContentBlock1":["2","22"]
I have been trying to get the 2 and the 22 into a comma sepertaed string so i can use it within a MySQL IN(2,22) query.
I currently have tried several ways but none seem to work for me.
$ContentBlock = my json data;
$cid = json_decode($ContentBlock,true);
foreach ($cid as $key){
$jsoncid = "$key ,";
}
And then:
SELECT * FROM content
WHERE featured=1 AND state=1 AND catid IN($jsoncid)
ORDER BY ordering ASC LIMIT 4");