count
count — Count all elements in an array, or something in an object.Description
Description
count( Countable|array $value,Counts all elements in an array, or something in an object. For objects, if you have SPL installed, you can hook into count() by implementing interface Countable. The interface has exactly one method, Countable::count(), which returns the return value for the count() function. Please see the Array section of the manual for a detailed explanation of how arrays are implemented and used in PHP.
int $mode = COUNT_NORMAL ): int
Parameters
value
An array or Countable object.
mode
If the optional mode parameter is set to COUNT_RECURSIVE (or 1), count() will recursively count the array. This is particularly useful for counting all the elements of a multidimensional array.
Return Values
Returns the number of elements in value. When the parameter is neither an array nor an object with implemented Countable interface, 1 will be returned. There is one exception, if value is null, 0 will be returned.More information about count on official PHP documentation site
count - Popular snippets
- PHP 7.4 / MySQL 5.7 mt_rand count print_r
last run:
2023-03-15 14:02:45
53
- PHP 8.0 / MySQL 8.0 count implode array_fill str_repeat
last run:
2024-12-02 19:35:21
23
- PHP 8.1 / MySQL 5.7 rand count in_array
last run:
2024-12-06 17:33:57
22
- PHP 8.1 / MySQL 5.7 count array_merge array_splice rand print_r
last run:
2024-12-05 17:34:59
21
- PHP 8.0 / MySQL 5.7 str_split count printf
last run:
2024-04-25 12:49:47
20
- PHP 8.1 / MySQL 5.7 count var_dump
last run:
2022-07-31 11:04:29
19
- PHP 8.1 / MySQL 5.7 base64_decode preg_match_all count str_replace chr hexdec preg_match
last run:
2023-11-12 20:14:19
17
- PHP 7.4 / MySQL 5.7 count rand
last run:
2022-07-02 08:55:29
17
- PHP 8.1 / MySQL 5.7 array_map count min max array_values array_reduce print_r
last run:
2022-10-19 12:12:55
16
- PHP 8.0 / MySQL 8.0 count implode array_fill str_repeat array_merge
last run:
2024-03-01 04:51:33
16
count - New snippets
-
PHP 8.1 / SQLite 3 Preloaded count
added at:
2024-12-09 15:14:56
1
-
PHP 8.1 / MySQL 5.7 count is_int implode var_dump
added at:
2024-12-07 19:44:13
1
-
PHP 8.1 / MySQL 5.7 count is_int implode var_dump
added at:
2024-12-07 19:43:55
1
-
PHP 8.1 / MySQL 5.7 count is_int implode var_dump
added at:
2024-12-07 19:43:08
1
-
PHP 8.1 / MySQL 5.7 count is_int implode var_dump
added at:
2024-12-07 19:43:03
1
-
PHP 8.1 / MySQL 5.7 count is_int implode var_dump
added at:
2024-12-07 19:42:39
3
-
PHP 8.1 / MySQL 5.7 count implode var_dump
added at:
2024-12-07 19:41:27
1
-
PHP 8.1 / MySQL 5.7 count implode
added at:
2024-12-07 19:41:08
1
-
PHP 8.1 / MySQL 5.7 count implode
added at:
2024-12-07 19:40:28
2
-
PHP 8.1 / MySQL 5.7 count implode var_dump
added at:
2024-12-07 19:39:42
1