code: protected function preserveLines($data, bool $reverse)
      {
          $search = ["\n", "\r"];
          $replace = ['\\n', '\\r'];
  
          if ($reverse) {
              $search = ['\\n', '\\r'];
              $replace = ["\n", "\r"];
          }
  
          if (is_string($data)) {
              $data = str_replace($search, $replace, $data);
          } elseif (is_array($data)) {
              foreach ($data as &$value) {
                  $value = $this->preserveLines($value, $reverse);
              }
              unset($value);
          }
  
          return $data;
      }
docs: Preserve new lines, recursive function.
  
  @param mixed $data
  @param bool $reverse
  
  @return mixed