Count total of subarrays with certain values in PHP

前端 未结 2 1221
夕颜
夕颜 2021-01-23 16:28
$example = 
  array
    \'test\' =>
      array(
        \'something\' => \'value\'
      ),
    \'whatever\' =>
      array(
        \'something\' => \'othe         


        
2条回答
  •  青春惊慌失措
    2021-01-23 16:53

    You can try the following:

    $count = 0;
    foreach( $example as $value ) {
        if( in_array("other", $value ) )
            $count++;
    }
    

提交回复
热议问题