Updating or adding data to an associative array as a cache
Modify the code to this:

//just use the AND operator (&amp;&amp;) to check if it's both existing AND valid
//use strict comparison (===) whenever possible
if(array_key_exists($key,$cachetable) &amp;&amp; $cachetable[$key] === $newdata[$key]){
    //data exists and valid
} else {
    //data doesn't exist or isn't valid
    //to assign data, use a single equal (=). 
    //A double equal (==) is a loose comparison
    $cachetable[$key] = $newdata[$key];
 }




//this one checks if it's not in the array
//or if it does, it checks if it's not valid
//when either one is true, the condition passes
if(!array_key_exists($key,$cachetable) || $cachetable[$key] !== $newdata[$key]){
    //data doesn't exists or isn't valid
}