public static function replace_key(array $array, $oldKey, $newKey) : array
  {
    $newArray = array();

    foreach ($array as $key => $value) {
      if ($key == $oldKey) {
        $newArray = array_merge($newArray, [$newKey => $value]);
      } else {
        $newArray = array_merge($newArray, [$key => $value]);
      }
    }

    return $newArray;
  }
public static function replace_key(array $array, $oldKey, $newKey) : array
  {
    $newArray = array();

    foreach ($array as $key => $value) {
      if ($key == $oldKey) {
        $newArray = array_merge($newArray, [$newKey => $value]);
      } else {
        $newArray = array_merge($newArray, [$key => $value]);
      }
    }

    return $newArray;
  }
public static function replace_key ( array $ array , $ oldKey , $ newKey ) : array { $ newArray = array ( ) ; foreach ( $ array as $ key => $ value ) { if ( $ key == $ oldKey ) { $ newArray = array_merge ( $ newArray , [ $ newKey => $ value ] ) ; } else { $ newArray = array_merge ( $ newArray , [ $ key => $ value ] ) ; } } return $ newArray ; }
Replace array key

@param array $array
@param mixed $oldKey
@param mixed $newKey
@return array $newArray
Replace array key