I\'m reading JSON data with PHP and that data contains empty objects (like {}). So the problem is, I have to handle the case when object is empty in different m
I am not sure if this is more or less effective than casting to an array but I would guess more. You could just start to loop the object and as soon as you find something you have an answer and stop looping.
function is_obj_empty($obj){
if( is_null($obj) ){
return true;
}
foreach( $obj as $key => $val ){
return false;
}
return true;
}