Php > Strings
A very useful function to display text on specified number of characters
A very useful function to display text on specified number of characters A very easy and useful function to display text on specified number of characters on the fly. This function cut the text on the basis of word boundary. Here is the function function cuttext($text, $maxChars = 20, $tail = "") { $arrWords = explode(" ", $text); $temp = ""; for ($i=0; $i
$maxChars) return $returnStr.$tail; else return $returnStr; } } return $returnStr; } ************** EXAMPLE **************** $string = "A quick brown fox jumps over the lazy dog."; echo cuttext($string, 30, "..."); ************** OUT PUT **************** ?> A quick brown fox jumps over...
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage