public static function walkQuery(array $query, $keyPrefix, callable $prefixer)
    {
        $result = [];
        foreach ($query as $key => $value) {
            if ($keyPrefix) {
                $key = $prefixer($key, $keyPrefix);
            }
            if (is_array($value)) {
                $result += self::walkQuery($value, $key, $prefixer);
            } elseif (isset($result[$key])) {
                $result[$key][] = $value;
            } else {
                $result[$key] = array($value);
            }
        }

        return $result;
    }
public static function walkQuery(array $query, $keyPrefix, callable $prefixer)
    {
        $result = [];
        foreach ($query as $key => $value) {
            if ($keyPrefix) {
                $key = $prefixer($key, $keyPrefix);
            }
            if (is_array($value)) {
                $result += self::walkQuery($value, $key, $prefixer);
            } elseif (isset($result[$key])) {
                $result[$key][] = $value;
            } else {
                $result[$key] = array($value);
            }
        }

        return $result;
    }
public static function walkQuery ( array $ query , $ keyPrefix , callable $ prefixer ) { $ result = [ ] ; foreach ( $ query as $ key => $ value ) { if ( $ keyPrefix ) { $ key = $ prefixer ( $ key , $ keyPrefix ) ; } if ( is_array ( $ value ) ) { $ result += self :: walkQuery ( $ value , $ key , $ prefixer ) ; } elseif ( isset ( $ result [ $ key ] ) ) { $ result [ $ key ] [ ] = $ value ; } else { $ result [ $ key ] = array ( $ value ) ; } } return $ result ; }
Easily create query aggregation functions by providing a key prefix
function to this query string array walker.

@param array    $query     Query string to walk
@param string   $keyPrefix Key prefix (start with '')
@param callable $prefixer  Function used to create a key prefix

@return array
Easily create query aggregation functions by providing a key prefix function to this query string array walker .