I'm having these two arrays
$expectedArray = [
'mainKey1' => [
'subKey1.1' => 'Value 1',
'subKey1.2' => 'Value 2',
'subKey1.3' => 'Value 3',
],
'mainKey2' => [
'subKey2.1' => 'Value 21',
'subKey2.2' => 'Value 22',
'subKey2.3' => 'Value 23',
],
];
$outputArray = [
'mainKey1' => [
'subKey1.1' => 'Value 1',
'subKey1.2' => 'Value 2',
'subKey1.3' => 'Value 3',
],
'mainKey2' => [
'subKey2.1' => 'Value 21',
'subKey2.2' => 'Value 22',
'subKey2.3' => 'Value 23',
],
];
I'm using the same function as here PHPUnit: assert two arrays are equal, but order of elements not important so
function arrays_are_similar($a, $b) {
// if the indexes don't match, return immediately
if (count(array_diff_assoc($a, $b))) {
return false;
}
// we know that the indexes, but maybe not values, match.
// compare the values between the two arrays
foreach($a as $k => $v) {
if ($v !== $b[$k]) {
return false;
}
}
// we have identical indexes, and no unequal values
return true;
}
but this returns me an error [PHPUnit\Framework\Exception] Array to string conversion
Any ideas what Im doing wrong?