_drupal_html_to_text_pad

Versions
6 – 7
_drupal_html_to_text_pad($text, $pad, $prefix = '')

Helper function for drupal_html_to_text().

Pad the last line with the given character.

▾ 1 function calls _drupal_html_to_text_pad()

drupal_html_to_text in includes/mail.inc
Transform an HTML string into plain text, preserving the structure of the markup. Useful for preparing the body of a node to be sent by e-mail.

Code

includes/mail.inc, line 470

<?php
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));
  // Add prefix and padding, and restore linebreak.
  return $text . $prefix . str_repeat($pad, $n - strlen($prefix)) ."\n";
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.