Comparing 2 json strings to find new entries Comparing 2 json strings to find new entries json json

Comparing 2 json strings to find new entries


array_diff_assoc is the way to get difference of associative arrays:

$json = json_decode(file_get_contents("new.json"), true);$last_json = json_decode(file_get_contents("last.json"), true);$difference = array_diff_assoc($json, $last_json);print_r($difference); 

This small piece of code will find out if any whitelist_name is different in the new json than the old one

foreach($last_json as $key=>$value){    if($value['whitelist_name'] != $json[$key]['whitelist_name']){        // value is changed    }else{        // value is not changed    }}