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 / MySQL 5.7 count rand
last run:
2022-07-02 08:55:29
17
- PHP 8.0 / MySQL 5.7 str_split count printf
last run:
2022-06-29 05:55:14
13
- PHP 7 / MySQL 8.0 mysqli_query mysqli_fetch_assoc explode count array_push trim array_count_values array_keys print_r
last run:
2022-06-20 17:48:19
11
- PHP 7 / MySQL 5.7 count var_dump
last run:
2022-04-28 11:50:39
11
- PHP 7 / MySQL 5.7 microtime round count var_dump
last run:
2021-04-14 10:35:54
9
- PHP 8.0 / MySQL 5.7 count print_r
last run:
2022-02-19 11:44:40
8
- PHP 7 / MySQL 8.0 mysqli_query mysqli_fetch_assoc explode count array_push trim print_r array_count_values
last run:
2022-06-20 17:40:11
8
- PHP 8.0 / MySQL 8.0 count implode array_fill str_repeat
last run:
2022-06-08 13:46:54
7
- PHP 7 / MySQL 5.7 count implode var_dump
last run:
2021-06-21 20:48:59
7
- PHP 7 / MySQL 5.7 array_column array_fill count var_dump
last run:
2021-10-24 16:30:40
6
count - New snippets
-
PHP 8.1 / MySQL 5.7 count
added at:
2022-07-02 15:35:08
1
-
PHP 8.1 / MySQL 5.7 count
added at:
2022-07-02 15:34:42
1
-
PHP 7 / MySQL 5.7 count rand
added at:
2022-07-02 08:45:22
3
-
PHP 7 / MySQL 5.7 count array_rand
added at:
2022-07-02 08:44:14
1
-
PHP 7 / MySQL 5.7 count rand
added at:
2022-07-02 08:41:20
17
-
PHP 8.1 / MySQL 5.7 count rand
added at:
2022-07-02 08:41:09
1
-
PHP 8.1 / MySQL 5.7 count rand count rand
added at:
2022-07-02 08:40:30
1
-
PHP 7 / MySQL 5.7 strtolower file_exists explode count in_array copy
added at:
2022-06-30 20:46:53
2
-
PHP 5 / MySQL 5.7 explode count in_array copy
added at:
2022-06-30 20:46:17
1