skyknight Posted February 27, 2006 Posted February 27, 2006 I have text with 500 letters length and i want oscom display only 50 letters from 500 letters. Any idea or tips? Thank alot Kurniawan
211655 Posted February 27, 2006 Posted February 27, 2006 Pass your variable to this function. add this function to your functions library <?php /** * Add this to your page: * <?php * include "shorten_a_text_string.php"; * echo ShortenText($text); * ?> * where $text is the text you want to shorten. * * Example * Test it using this in a PHP page: * <?php * include "shortentext.php"; * $text = "The rain in Spain falls mainly on the plain."; * echo ShortenText($text); * ?> */ function ShortenText($text) { // Change to the number of characters you want to display $chars = 50; $text = $text." "; $text = substr($text,0,$chars); $text = substr($text,0,strrpos($text,' ')); $text = $text."..."; return $text; } ?> 211655 SEO Optimization Export Orders into CSV file
Recommended Posts
Archived
This topic is now archived and is closed to further replies.