note 84103 added to function.substr

From: Date: Fri, 27 Jun 2008 20:09:31 +0000
Subject: note 84103 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-140883@lists.php.net to get a copy of this message
joao dot martins at plako dot net 26-Mar-2008 09:14 ben at enemy dot dk 10-Feb-2008 05:48 Updated function. The previous one will return empty value if the $string has no letter spaces. This is usefull if some of your strings have only one word. function cutText($string, $setlength) { $length = $setlength; if($length<strlen($string)){ while (($string{$length} != " ") AND ($length > 0)) { $length--; } if ($length == 0) return substr($string, 0, $setlength); else return substr($string, 0, $length); }else return $string; } ---- Server IP: 147.32.160.17 Probable Submitter: 83.240.76.94 ---- Manual Page -- http://www.php.net/manual/en/function.substr.php Edit -- https://master.php.net/note/edit/84103 Del: integrated -- https://master.php.net/note/delete/84103/integrated Del: useless -- https://master.php.net/note/delete/84103/useless Del: bad code -- https://master.php.net/note/delete/84103/bad+code Del: spam -- https://master.php.net/note/delete/84103/spam Del: non-english -- https://master.php.net/note/delete/84103/non-english Del: in docs -- https://master.php.net/note/delete/84103/in+docs Del: other reasons-- https://master.php.net/note/delete/84103 Reject -- https://master.php.net/note/reject/84103 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140883) next »