I am trying to compare 2 json strings with each other to find all new entries in the list.
This is how I am comparing them:
$json = json_decode(file_get_contents("new.json"), true);
$last_json = json_decode(file_get_contents("last.json"), true);
$difference = array_diff($json, $last_json);
print_r($difference);
I am expecting it to return an array with all new entries. However, I am just getting an empty array in return.
Any help would be appreciated!
Additional information: I am also trying to compare the values of the arrays. This is how I'm trying to do that:
foreach($json["whitelist_name"] AS $json_key => $json_val) {
foreach($last_json["whitelist_name"] AS $last_json_key => $last_json_val) {
if($json["whitelist_name"] != $last_json["whitelist_name"]) {
echo $json["whitelist_name"];
}
}
}
However, it seems that $json["whitelist_name"] is undefined