/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * word-sensitive substring function with html tags awareness * @param text The text to cut * @param len The maximum length of the cut string * @returns string **/ function substrws( $text, $len=180 ) { if( $whitespaceposition > 0 ) // close unclosed html tags foreach( $aBuffer[1] as $index => $tag ) { $text .= '</'.$tag.'>'; } } } } } return $text; } ?>