我在php中有一个多维数组。
现在我想使用范围值搜索数据,例如我想获得拥有business_point>的商家名称。 0.0和business_point< 2.0。
我知道如何在数组中搜索值,但是我无法计算如何使用范围进行搜索,这是否可能?
因此,对于正常搜索,我使用此代码:
function search_array_data($options, $key, $check)
{
$results = array();
$i = 0;
foreach ($options as $itemKey => $itemValue) {
if (in_array($itemValue[$key],$check)) {
$results[]=$itemValue;
}
$i++;
}
return $results;
}
这是我的数据数组:
Array
(
[0] => Array
(
[Business_name] => 1847(Jumeirah)
[Business_id] => 1422
[business_point] => 1.5
)
[1] => Array
(
[Business_name] => 1847 Mens Salon(Trade Centre)
[Business_id] => 42
[business_point] => 1.5
)
[2] => Array
(
[Business_name] => 1847 Mens Salon(Mirdif)
[Business_id] => 1565
[business_point] => 1.5
)
[3] => Array
(
[Business_name] => 1847 Mens Salon(City Walk)
[Business_id] => 494
[business_point] => 2.5
)
[4] => Array
(
[Business_name] => 1847 Mens Salon(Dubai Marina)
[Business_id] => 44
[business_point] => 3.5
)
[5] => Array
(
[Business_name] => 21 Ladies Saloon(Karama)
[Business_id] => 1394
[business_point] => 3.0
)
[6] => Array
(
[Business_name] => 515 Medspa Center(Jumeirah)
[Business_id] => 2125
[business_point] => 1.5
)
)