src/Tools/ArrayModifier.php
public static function aggregate($array, $specialKeys = self::SPECIALS_KEYS, $prefix = '')
    {
        $new = [];
        foreach ($array as $key => $value) {
            $newKey = (!empty($prefix)) ? $prefix . '.' . $key : $key;
            if (!in_array($key, $specialKeys, true) && !in_array($key, array_keys($specialKeys), true)) {
                if (is_a($value, "stdClass")) {
                    $value = (array) $value;
                }

                if (is_array($value)) {
                    $new += self::aggregate($value, $specialKeys, $newKey);
                } else {
                    $new[$newKey] = $value;
                }
            } else {
                if (array_key_exists($key, $specialKeys) && is_callable($specialKeys[$key])) {
                    $new = call_user_func($specialKeys[$key], $prefix, $key, $value, $new);
                }
            }
        }

        return $new;
    }
public static function aggregate($array, $specialKeys = self::SPECIALS_KEYS, $prefix = '')
    {
        $new = [];
        foreach ($array as $key => $value) {
            $newKey = (!empty($prefix)) ? $prefix . '.' . $key : $key;
            if (!in_array($key, $specialKeys, true) && !in_array($key, array_keys($specialKeys), true)) {
                if (is_a($value, "stdClass")) {
                    $value = (array) $value;
                }

                if (is_array($value)) {
                    $new += self::aggregate($value, $specialKeys, $newKey);
                } else {
                    $new[$newKey] = $value;
                }
            } else {
                if (array_key_exists($key, $specialKeys) && is_callable($specialKeys[$key])) {
                    $new = call_user_func($specialKeys[$key], $prefix, $key, $value, $new);
                }
            }
        }

        return $new;
    }
public static function aggregate ( $ array , $ specialKeys = self :: SPECIALS_KEYS , $ prefix = '' ) { $ new = [ ] ; foreach ( $ array as $ key => $ value ) { $ newKey = ( ! empty ( $ prefix ) ) ? $ prefix . '.' . $ key : $ key ; if ( ! in_array ( $ key , $ specialKeys , true ) && ! in_array ( $ key , array_keys ( $ specialKeys ) , true ) ) { if ( is_a ( $ value , "stdClass" ) ) { $ value = ( array ) $ value ; } if ( is_array ( $ value ) ) { $ new += self :: aggregate ( $ value , $ specialKeys , $ newKey ) ; } else { $ new [ $ newKey ] = $ value ; } } else { if ( array_key_exists ( $ key , $ specialKeys ) && is_callable ( $ specialKeys [ $ key ] ) ) { $ new = call_user_func ( $ specialKeys [ $ key ] , $ prefix , $ key , $ value , $ new ) ; } } } return $ new ; }
Aggregate an array to dot notation

@param   array   $array Input    array
@param   array   $specialKeys    array of key to not aggregate
@param   string  $prefix         prefix
@return  array
Aggregate an array to dot notation