You are here

function _drupal_html_to_text_pad in Drupal 7

Same name and namespace in other branches
  1. 6 includes/mail.inc \_drupal_html_to_text_pad()

Pads the last line with the given character.

See also

drupal_html_to_text()

1 call to _drupal_html_to_text_pad()
drupal_html_to_text in includes/mail.inc
Transforms an HTML string into plain text, preserving its structure.

File

includes/mail.inc, line 673
API functions for processing and sending e-mail.

Code

function _drupal_html_to_text_pad($text, $pad, $prefix = '') {

  // Remove last line break.
  $text = substr($text, 0, -1);

  // Calculate needed padding space and add it.
  if (($p = strrpos($text, "\n")) === FALSE) {
    $p = -1;
  }
  $n = max(0, 79 - (strlen($text) - $p) - strlen($prefix));

  // Add prefix and padding, and restore linebreak.
  return $text . $prefix . str_repeat($pad, $n) . "\n";
}