How can I count the number of element inside an array with value equals a constant? example,
$myArray = array(\"Kyle\",\"Ben\",\"Sue\",\"Phil\",\"Ben\",\"Mar
In my case of two dimensional array, from PHP Official Page comments, I found the useful snippet for a two dimensional array-
1, 'userId' => 5], ['id' => 2, 'userId' => 5], ['id' => 3, 'userId' => 6], ]; $userId = 5; echo array_count_values(array_column($list, 'userId'))[$userId]; // outputs: 2 ?>