note 84104 added to function.strlen

From: Date: Fri, 27 Jun 2008 21:06:42 +0000
Subject: note 84104 added to function.strlen
Groups: php.notes 
Request: Send a blank email to php-notes+get-140884@lists.php.net to get a copy of this message
Improved version of 'php at capcarrere dot org's "nicetrim" function: <? // Trim a string to specified legnth and append an end character (default = ...) function str_trim($str, $lim = 32, $chr = '&#8230;') { // If length of string is less than $lim, return string if (strlen($str = html_entity_decode($str)) <= $lim) return $str; // Else, cut string down to size return htmlentities(substr($str, 0, $lim - 3)).$chr; } ?> ---- Server IP: 209.41.74.194 Probable Submitter: 70.179.13.145 ---- Manual Page -- http://www.php.net/manual/en/function.strlen.php Edit -- https://master.php.net/note/edit/84104 Del: integrated -- https://master.php.net/note/delete/84104/integrated Del: useless -- https://master.php.net/note/delete/84104/useless Del: bad code -- https://master.php.net/note/delete/84104/bad+code Del: spam -- https://master.php.net/note/delete/84104/spam Del: non-english -- https://master.php.net/note/delete/84104/non-english Del: in docs -- https://master.php.net/note/delete/84104/in+docs Del: other reasons-- https://master.php.net/note/delete/84104 Reject -- https://master.php.net/note/reject/84104 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140884) next »