24 PHP Array Functions-11 | array_rand and array_reduce | ATIBlog

24. PHP array functions tutorial in Hindi by ATIBlog.

array_rand ( $array, $num );
array_reduce ( $array, callback $function [, int $initial] );

1. array_rand()
This function is used to select random values from the passed array.
It returns the random value from the array.
You can select more than one random values too, by passing the second parameter (optional)(number of random values to get). It will return an array of random values if number is greater than one. By default, this number is set to one.

2.array_reduce()
This function is used to use the array as a single value.
First parameter is the array to work on.
Second parameter is the callback function used to reduce.
(optional)Third parameter is the initial value of the reduced array.

source