-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
count.php
40 lines (36 loc) 路 755 Bytes
/
count.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
declare(strict_types=1);
namespace Psl\Arr;
use Psl\Iter;
/**
* Returns the number of elements an array contains.
*
* This function is not recursive, it counts only the number of elements in the
* array itself, not its children.
*
* Examples:
*
* Arr\count([1, 2, 3])
* => Int(3)
*
* Arr\count(Arr\flatten([[1, 2, 3], [4], [5, 6], [7, 8]]))
* => Int(3)
*
* Arr\count(Arr\flatten([[1, 2, 3], [4], [5, 6], [3 => 7, 4 => 8]]))
* => Int(5)
*
* @psalm-template Tk of array-key
* @psalm-template Tv
*
* @psalm-param array<Tk, Tv> $array
*
* @psalm-pure
*
* @deprecated since 1.2, use Iter\count instead.
*
* @see Iter\count()
*/
function count(array $array): int
{
return \count($array);
}