The two arrays are considered equal since they have the same 1st dimension indexes (Electric, Gas, Water) the same 2nd dimension indexes (Gym, Library), and the same values for each intersect. The values will always be literals and not arrays or objects. Order doesn't mater.
How can PHP verify that they are equal based on the above definition of equality?
Array
(
[Electric] => Array
(
[Gym] => 24
[Library] => 25
)
[Gas] => Array
(
[Gym] => 13
[Library] =>
)
[Water] => Array
(
[Gym] =>
[Library] =>
)
)
Array
(
[Gas] => Array
(
[Library] =>
[Gym] => 13
)
[Electric] => Array
(
[Gym] => 24
[Library] => 25
)
[Water] => Array
(
[Library] =>
[Gym] =>
)
)
EDIT. My attempt is as follows...
if(count($arr1) != count($arr2) || array_diff($arr1, $arr2) !== array_diff($arr2, $arr1)) {
$error='Values do not match.';
}