$array = array('test0','test1','test2');
$array1 = array('test0','test1','test2','test1');
$key = array_search('test1',$array);
$key1 = array_search('test1',$array1);
echo $key;
echo $key1;
输出都是1
如果有重复的value输出第一个相匹配的key
欢迎各位兄弟 发布技术文章
这里的技术是共享的
$array = array('test0','test1','test2'); $array1 = array('test0','test1','test2','test1'); $key = array_search('test1',$array); $key1 = array_search('test1',$array1); echo $key; echo $key1; 输出都是1 如果有重复的value输出第一个相匹配的key