i have multidimensional array in php.
now want search data using range values, want name of business have business_point > 0.0 , business_point < 2.0.
i know how search values in array ,but i'am not able figure how go searching using range, possible?
so normal searching using code:
function search_array_data($options, $key, $check) { $results = array(); $i = 0; foreach ($options $itemkey => $itemvalue) { if (in_array($itemvalue[$key],$check)) { $results[]=$itemvalue; } $i++; } return $results; }
this array of data:
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 ) )
you can use array_map function
$result = array_filter(array_map('vas',$ararr)); function vas($t){ if($t['business_point'] > 0 && $t['business_point'] < 2.0){ return $t; } }
you can check over here
Comments
Post a Comment