编程思路:对数组进行遍历,依次进行比较
function query_search($param,$arr=[])
{
if(!is_array($arr))return false;
$k = [];
foreach($arr as $key => $value){
if($value== $info){
$k[] = $key;
}
}
if(empty($k)return false;
return $k;
}
$result = query_search(7,$arr=[1,2,3,4,5,6,7]);
print_r($result);
网友评论