Last active
December 17, 2015 18:09
-
-
Save panfeng/5651450 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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