array_reduce
array_reduce — Iteratively reduce the array to a single value using a callback function.Description
array_reduce( array $array,array_reduce() applies iteratively the callback function to the elements of the array, so as to reduce the array to a single value.
callable $callback,
mixed $initial = null ): mixed
Parameters
array
The input array.
callback
The callback function. callback(mixed $carry, mixed $item): mixed
initial
If the optional initial is available, it will be used at the beginning of the process, or as a final result in case the array is empty.
Return Values
Returns the resulting value.If the array is empty and initial is not passed, array_reduce() returns null.
More information about array_reduce on official PHP documentation site
array_reduce - Popular snippets
- PHP 8.0 / MySQL 5.7 var_export json_decode array_reduce array_values
last run:
2023-11-30 18:57:30
29
- PHP 8.0 / MySQL 5.7 array_reduce print_r array_values
last run:
2024-04-08 17:41:59
26
- PHP 8.0 / MySQL 5.7 str_getcsv array_reduce
last run:
2024-04-16 07:33:39
22
- 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 7.4 / MySQL 5.7 array_reduce array_merge unserialize array_count_values arsort
last run:
2021-10-20 07:49:30
14
- PHP 8.0 / MySQL 5.7 array_reduce array_merge unserialize print_r array_count_values
last run:
2023-10-19 10:30:42
13
- PHP 8.0 / MySQL 5.7 mt_rand strtotime array_reduce date is_null print_r
last run:
2021-11-11 15:08:49
11
- PHP 5.6 / MySQL 5.7 array_reduce array_merge unserialize print_r array_count_values
last run:
2021-10-19 13:38:35
11
- PHP 7.4 / MySQL 5.7 array_reduce print_r
last run:
2024-04-17 19:28:41
10
- PHP 8.0 / MySQL 5.7 mt_rand strtotime array_reduce date is_null print_r
last run:
2021-11-11 15:09:28
10
array_reduce - New snippets
-
PHP 8.1 / MySQL 5.7 array_reduce explode trim array_push print_r
added at:
2024-03-02 13:06:51
1
-
PHP 8.2.13 / MySQL 8.0 var_dump array_merge implode array_fill count array_reduce
added at:
2024-02-15 14:30:42
2
-
PHP 8.2.13 / MySQL 8.0 Sakila (ReadOnly) array_fill count implode array_reduce array_merge array_values var_export
added at:
2024-02-15 12:16:27
1
-
PHP 8.2.13 / MySQL 8.0 Sakila (ReadOnly) array_fill count implode array_reduce array_merge array_values var_export
added at:
2024-02-15 12:16:22
1
-
PHP 7.4 / MySQL 5.7 array_reduce print_r
added at:
2024-02-07 20:47:08
2
-
PHP 7.4 / MySQL 5.7 array_reduce print_r
added at:
2024-02-07 20:46:39
1
-
PHP 7.4 / MySQL 5.7 array_reduce print_r
added at:
2024-02-07 20:45:58
1
-
PHP 7.4 / MySQL 5.7 array_reduce print_r
added at:
2024-02-07 20:45:43
1
-
PHP 7.4 / MySQL 5.7 array_reduce print_r
added at:
2024-02-07 20:45:26
1
-
PHP 7.4 / MySQL 5.7 array_reduce print_r
added at:
2024-02-07 20:45:11
1