PHP - count specific array values
To count a value in a two dimensional array, here is the useful snippet to process and get count of a particular value-
<?php $list = [ ['id' => 1, 'userId' => 5], ['id' => 2, 'userId' => 5], ['id' => 3, 'userId' => 6], ]; $userId = 5; echo array_count_values(array_column($list, 'userId'))[$userId]; // outputs: 2