1<?PHP2 //set the request header3 Header("Content-type:text/html;charset=utf-8");4 5 /*6 Sequential Lookups:7 Source: An array8 Requirement: Find out if there is a value, find it and return the subscript, no return hint9 */Ten One $arr=Array(1,6,3,100,9,100,0,7,-4,0); A - functionSearch (&$arr,$number 1,$number 2){ - the foreach($arr as $key=$value){ - - if($value==$number 1){ - $number 1_index=$key; + $flag 1=true; - $num 1_arr[] =$key;//more than the specified bidding clubs auto-fill, starting from 0 + } A at Else if($value==$number 2){ - $number 2_index=$key; - $flag 2=true; - $num 2_arr[] =$key; - } - } in - if($flag 1||$flag 2){ to Echo $number 1. "There are in this array."Count($num 1_arr) . "One, the location is:".Var_dump($num 1_arr) . ' <br> '; + Echo $number 2. "There are in this array."Count($num 2_arr) . "One, the location is:".Var_dump($num 2_arr) . ' <br> '; - Exit; the } * $ Panax Notoginseng Echo"<script>alert (' No number you're looking for!!! ') </script> "; - Exit; the } + ASearch$arr, 100, 0); the +?>
Array Lookup Order Lookup-php