Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Last active December 8, 2023 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziadoz/ab4833697b5b0135a2f1a4ed0becc2e8 to your computer and use it in GitHub Desktop.
Save ziadoz/ab4833697b5b0135a2f1a4ed0becc2e8 to your computer and use it in GitHub Desktop.
PHP - Get Maximum Count of Multi-Dimensional Array
<?php
// @see: https://stackoverflow.com/questions/2189479/get-the-maximum-value-from-an-element-in-a-multidimensional-array
$array = [
'foo' => [1, 2, 3],
'bar' => [1],
'baz' => [1, 2],
];
echo count(max($array)); // 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment