统计二维数组中某个值出现的次数

$data =[

        '0' =>[
        
            'id' => 7,
            'patient_id' => 1,
            'arr1' => 高,
        ],
        '1' =>[
            'id' => 11,
            'patient_id' => 1,
            'arr1' => 低,
        ],
        '2' => [
            'id' => 13,
            'patient_id' => 1,
            'arr1' => 低,
        ]
    ];

解决:
$one['period']=isset(array_count_values(array_column($arr,'policy_status'))[0])?array_count_values(array_column($arr,'policy_status'))[0]:0;

  

posted @ 2020-05-16 11:25  zwb8032fang  阅读(759)  评论(0编辑  收藏  举报