note 87438 added to function.explode

From: Date: Fri, 05 Dec 2008 05:02:07 +0000
Subject: note 87438 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-147663@lists.php.net to get a copy of this message
// Remove words if more than max allowed character are insert or add a string in case less than min are displayed // Example: LimitText("The red dog ran out of thefence",15,20,"<br>"); function LimitText($Text,$Min,$Max,$MinAddChar) { if (strlen($Text) < $Min) { $Limit = $Min-strlen($Text); $Text .= $MinAddChar; } elseif (strlen($Text) >= $Max) { $words = explode(" ", $Text); $check=1; while (strlen($Text) >= $Max) { $c=count($words)-$check; $Text=substr($Text,0,(strlen($words[$c])+1)*(-1)); $check++; } } return $Text; } ---- Server IP: 208.69.120.35 Probable Submitter: 69.116.58.221 ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- https://master.php.net/note/edit/87438 Del: integrated -- https://master.php.net/note/delete/87438/integrated Del: useless -- https://master.php.net/note/delete/87438/useless Del: bad code -- https://master.php.net/note/delete/87438/bad+code Del: spam -- https://master.php.net/note/delete/87438/spam Del: non-english -- https://master.php.net/note/delete/87438/non-english Del: in docs -- https://master.php.net/note/delete/87438/in+docs Del: other reasons-- https://master.php.net/note/delete/87438 Reject -- https://master.php.net/note/reject/87438 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#147663) next »