update page now
Laravel Live Japan

Voting

: seven plus one?
(Example: nine)

The Note You're Voting On

sergolucky96 at gmail dot com
8 years ago
Simple way to find number of items with specific values in multidimensional array:

<?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
?>

<< Back to user notes page

To Top