In my company's code I stumbled about the following use-case of in_array()
: (replica of what happens)
$theHystack = [
'id' => 3,
'location' => 'Berlin'
];
$theNeedle = [
'id' => 3,
'location' => 'Berlin'
];
echo in_array($theNeedle, $theHystack, true)
? 'true'
: 'false';
The documentation of in_array
states that $needle
can be of type mixed
therefore it might be possible that this works.
To be certain I started to play around with the shown code however the result was always the same.
All results were false
The scenario was actually !in_array()
thus it should return always true
.
Question:
Is there a way of creating such a validation where you could validate an associative array with another associative array?
I'm looking for build-in php functions that could do something.