You could use following logic to remove elements from your source data:
The recursive function cleanUp()
cycles through the data and removes all the entries with values that are set in array $remove
$arr = json_decode($json, true);
$remove = ['N/A', '-','',];
cleanUp($arr, $remove);
function cleanUp(array &$arr, array $remove = [])
{
foreach($arr as $key => &$value) {
if(is_array($value)) {
cleanUp($value, $remove);
} else {
if(in_array($value, $remove)) unset($arr[$key]);
}
}
}
working demo
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…