I am writing a recursive function to print out the differences between 2 multildimensional php arrays. The purpose of this code is to see the difference between jpeg headers to deteremine how adobe bridge cs3 is saving rating information within the jpg file.
When I am single-stepping through the code using my eclipse - zend debugger ide, it appears that even though the initial if statement is false (ie both values are arrays), the subsequent elseif statements are never executed. The function is attached below.
function array_diff_multi($array1,$array2,$level){
$keys = array_keys($array1);
foreach($keys as $key)
{
$value1 = $array1[$key];
if(array_key_exists($key,$array2) ){
$value2 = $array2[$key];
// Check if they are both arrays, if so recursion is needed
if (is_array($value1) && is_array($value2)){
array_diff_multi($value1,$value2,$level . "[ " . $key . " ]");
}
// the values aren't both arrays *** THE CODE IN THE ELSEIF BELOW IS NOT EXECUTED ***
elseif(is_array($value1) != is_array($value2)){
print "" . $level . $key ."=" . $value1 . "as array, compared to ". $value2 ."";
}
// the values don't match
elseif($value1 != $value2){
print "" . $level . $key ."=" . $value1 ." != " . $value2 ."";
}
else;
}
else{
print "" . $level. $key . "does not exist in array2";
}
}
}