in_array() and multidimensional array

前端 未结 22 1353
眼角桃花
眼角桃花 2020-11-22 00:30

I use in_array() to check whether a value exists in an array like below,

$a = array(\"Mac\", \"NT\", \"Irix\", \"Linux\");
if (in_array(\"Irix\"         


        
22条回答
  •  悲&欢浪女
    2020-11-22 01:10

    It works too creating first a new unidimensional Array from the original one.

    $arr = array("key1"=>"value1","key2"=>"value2","key3"=>"value3");
    
    foreach ($arr as $row)  $vector[] = $row['key1'];
    
    in_array($needle,$vector);
    

提交回复
热议问题