note 70574 added to function.explode

From: Date: Fri, 20 Oct 2006 18:50:03 +0000
Subject: note 70574 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-118864@lists.php.net to get a copy of this message
// simple function to remove words if more than max allowed words or add a charcter once less than min // 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: 64.71.164.2 Probable Submitter: 66.246.83.2 ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- https://master.php.net/note/edit/70574 Del: integrated -- https://master.php.net/note/delete/70574/integrated Del: useless -- https://master.php.net/note/delete/70574/useless Del: bad code -- https://master.php.net/note/delete/70574/bad+code Del: spam -- https://master.php.net/note/delete/70574/spam Del: non-english -- https://master.php.net/note/delete/70574/non-english Del: in docs -- https://master.php.net/note/delete/70574/in+docs Del: other reasons-- https://master.php.net/note/delete/70574 Reject -- https://master.php.net/note/reject/70574 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#118864) next »