public static function random(array $array, int $amount = null)
    {
        if (is_null($amount)) {
            return $array[array_rand($array)];
        }

        $keys = array_rand($array, $amount);

        $results = [];

        foreach ((array) $keys as $key) {
            $results[] = $array[$key];
        }

        return $results;
    }
public static function random(array $array, int $amount = null)
    {
        if (is_null($amount)) {
            return $array[array_rand($array)];
        }

        $keys = array_rand($array, $amount);

        $results = [];

        foreach ((array) $keys as $key) {
            $results[] = $array[$key];
        }

        return $results;
    }
public static function random ( array $ array , int $ amount = null ) { if ( is_null ( $ amount ) ) { return $ array [ array_rand ( $ array ) ] ; } $ keys = array_rand ( $ array , $ amount ) ; $ results = [ ] ; foreach ( ( array ) $ keys as $ key ) { $ results [ ] = $ array [ $ key ] ; } return $ results ; }
Get a 1 value from an array.

@param array    $array
@param int|null $amount

@return mixed

@throws \InvalidArgumentException
Get a 1 value from an array .