src/Utilities/Arrays.php
public static function replaceArrayKeys($dataArray, $oldKeyPattern, $newKey)
    {
        $effect = [];

        if (is_array($dataArray) && !empty($dataArray)) {
            foreach ($dataArray as $key => $value) {
                if (preg_match($oldKeyPattern, $key)) {
                    $key = $newKey;
                }

                if (is_array($value)) {
                    $value = self::replaceArrayKeys($value, $oldKeyPattern, $newKey);
                }

                $effect[$key] = $value;
            }
        }

        return $effect;
    }
public static function replaceArrayKeys($dataArray, $oldKeyPattern, $newKey)
    {
        $effect = [];

        if (is_array($dataArray) && !empty($dataArray)) {
            foreach ($dataArray as $key => $value) {
                if (preg_match($oldKeyPattern, $key)) {
                    $key = $newKey;
                }

                if (is_array($value)) {
                    $value = self::replaceArrayKeys($value, $oldKeyPattern, $newKey);
                }

                $effect[$key] = $value;
            }
        }

        return $effect;
    }
public static function replaceArrayKeys ( $ dataArray , $ oldKeyPattern , $ newKey ) { $ effect = [ ] ; if ( is_array ( $ dataArray ) && ! empty ( $ dataArray ) ) { foreach ( $ dataArray as $ key => $ value ) { if ( preg_match ( $ oldKeyPattern , $ key ) ) { $ key = $ newKey ; } if ( is_array ( $ value ) ) { $ value = self :: replaceArrayKeys ( $ value , $ oldKeyPattern , $ newKey ) ; } $ effect [ $ key ] = $ value ; } } return $ effect ; }
Replaces array keys that match given pattern with new key name

@param array  $dataArray     The array
@param string $oldKeyPattern Old key pattern
@param string $newKey        New key name
@return array
Replaces array keys that match given pattern with new key name