in_array() and multidimensional array

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

    I found really small simple solution:

    If your array is :

    Array
    (
    [details] => Array
        (
            [name] => Dhruv
            [salary] => 5000
        )
    
    [score] => Array
        (
            [ssc] => 70
            [diploma] => 90
            [degree] => 70
        )
    
    )
    

    then the code will be like:

     if(in_array("5000",$array['details'])){
                 echo "yes found.";
             }
         else {
                 echo "no not found";
              }
    

提交回复
热议问题