Need help with cleaning json PHP

What is your question? What have you tried?

Hi Benanamen, yes i did, but there are still elements in the array with blank spaces. Not sure if i am missing something here:

<?php $ch= curl_init('https://coderbyte.com/api/challenges/json/json-cleaning');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
$newdata = json_decode($data,true);

foreach ($newdata as $key => $value) {

if(is_array($value)) {
foreach ($value as $about => $ddata) {

if($ddata == "" || $ddata == 'N/A' || $ddata == '-' ) {
unset($value[$about]); } } }
else{ if($value == "" || $value == 'N/A' || $value == '-' ) {
unset($newdata[$key]); } } }
var_dump($newdata);
curl_close($ch); ?>

* Admin added code tags

Look at the result of $data.

Sponsor our Newsletter | Privacy Policy | Terms of Service