in_array() and multidimensional array

前端 未结 22 1894
眼角桃花
眼角桃花 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:00

    I believe you can just use array_key_exists nowadays:

    "NT","Irix"=>"Linux");
    if (array_key_exists("Mac",$a))
      {
      echo "Key exists!";
      }
    else
      {
      echo "Key does not exist!";
      }
    ?>
    

提交回复
热议问题