* Name: highlight_char
* Date: March 8, 2004
* Purpose: highlight first character of the input string with css class
* Input: * - string = string whose first char should be wrapped in the given class * * Examples:
*
 * {$xxx|highlight_char:big_font}
 * Output:
 *   xxx
 *
 * {$xxx|highlight_char:none:b}	 {* you cannot leave a param empty, so none is no class *}
 * Output:
 *   xxx
 *
 * 
* @author Mark Hewitt * @version 1.0 * @param string $string Text to modify * @param string $css_class CSS classname to put in span tags, use 'none' to ignore * @param string $tag_name (Optional) Tag to wrap first char in * @param Smarty * @return string|null */ function smarty_modifier_highlight_char($string,$css_class,$tag_name="span") { // strip whitespace off the front of the string, and make sure // there are characters in the string, we only return valid characters... if ( ($s = trim($string)) != '' ) { $html = "<$tag_name"; if ( $css_class != 'none' ) $html .= ' class="'.$css_class.'"'; $html .= '>'.substr($s,0,1)."".substr($s,1); return $html; } else { return ''; } }