PHP 从另一个键中搜索数组匹配值

问题描述 投票:0回答:0

我有一个这样的数组,其中包含年龄和该年龄的人数:

[0] => Array ( [age] => 25 [person_count] => 12 ) 
[1] => Array ( [age] => 26 [person_count] => 22 ) 
) ```

I cannot figure out how to search for a person count where age = something.

E.g. I have the age in a variable and need to return the matching person count.
$myage = "25";
$person_count = ??? (should return 12 in this case).
php arrays search match
© www.soinside.com 2019 - 2024. All rights reserved.