htmlToTextClean example


  public static function wrapMail($text$indent = '') {
    // Convert CRLF into LF.     $text = str_replace("\r", '', $text);
    // See if soft-wrapping is allowed.     $clean_indent = static::htmlToTextClean($indent);
    $soft = !str_contains($clean_indent, ' ');
    // Check if the string has line breaks.     if (str_contains($text, "\n")) {
      // Remove trailing spaces to make existing breaks hard, but leave       // signature marker untouched (RFC 3676, Section 4.3).       $text = preg_replace('/(?(?<!^--) +\n| +\n)/m', "\n", $text);
      // Wrap each line at the needed width.       $lines = explode("\n", $text);
      array_walk($lines, '\Drupal\Core\Mail\MailFormatHelper::wrapMailLine', ['soft' => $soft, 'length' => strlen($indent)]);
      $text = implode("\n", $lines);
    }
    
Home | Imprint | This part of the site doesn't use cookies.