How to find whether a json array is empty or not using PHP? empty($jsonarray) seems doesn't work!
Assuming you have decoded the JSON, yes it does.
<?php
    $json = '{"hello": ["world"], "goodbye": []}';
    $decoded = json_decode($json);
    print "Is hello empty? " . empty($decoded->{'hello'});
    print "\n";
    print "Is goodbye empty? " . empty($decoded->{'world'});
    print "\n";
?>
gives:
Is hello empty?
Is goodbye empty? 1
Try this
if(count(json_decode($jsonarray,1))==0) {
    echo "empty";
}
//or
if(empty(json_decode($jsonarray,1))) {
    echo "empty";
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With