Skip to content

Instantly share code, notes, and snippets.

@panfeng
Last active December 17, 2015 18:09
Show Gist options
  • Save panfeng/5651450 to your computer and use it in GitHub Desktop.
Save panfeng/5651450 to your computer and use it in GitHub Desktop.
<?php
//php中php_array(1,$arr)只能查找出数组中第一次出现的$tofind;
$arr = array(1,2,3,4,1,1,1,1);
var_dump(array_search_all($arr,3));
//返回 value符合的key所组成的数组;
function array_search_all($obj_arr,$tofind,$return=array()){
for($i=0;$i<count($obj_arr);$i++){
if($obj_arr[$i]==$tofind){
$return[]+=$i;
}
}
return $return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment