I have the following array:
Array
(
[active_x] => 0
[active_y] => 0
[regions] => Array
(
[0] => Array
(
[x] => 0
[y] => 0
[name] => The Campground
[monsterProbability] => 5
[monsterDifficulty] => 1
[monsterType] => earth
)
)
)
This array can contain multiple arrays inside of the regions
key.
I'm creating a function that will give me the data for a specific region inside the regions
key, based on active_x
and active_y
.
I've tried using array_filter()
, but I get no return.
The array above is called $map
:
$x = $map['active_x'];
$y = $map['active_y'];
$data = array_filter($map['regions'], function ($var) {
return ($var['x'] == $x && $var['y'] == $y);
});
echo "<pre>".print_r($data, true)."</pre>";
How can I retrieve only the array containing the information for the specific active region?