Revision: 34735
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 27, 2010 21:23 by zoranmk
Initial Code
function compareAssociativeArrays($first_array, $second_array) { $result = array_diff_assoc($first_array, $second_array); if(!empty($result)) { //Arrays are different //print_r($result); will return the difference as key => value pairs. return FALSE; } else { //Arrays are same. //print_r($result); returns empty array. return TRUE; } } //Usage: $first = array( 'name' => 'Zoran', 'smart' => 'not really' ); $second = array( 'smart' => 'not really', 'name' => 'Zoran' ); if(compareAssociativeArrays($first, $second)) { echo 'Arrays are same'; } else { echo 'Arrays are different'; }
Initial URL
Initial Description
Initial Title
Compare two associative arrays
Initial Tags
array
Initial Language
PHP