note 70155 added to function.wordwrap

From: Date: Wed, 04 Oct 2006 22:12:46 +0000
Subject: note 70155 added to function.wordwrap
Groups: php.notes 
Request: Send a blank email to php-notes+get-118068@lists.php.net to get a copy of this message
Another function to cut text afterr $limit letters , function : function wordCut($text, $limit, $msg){ if (strlen($text) > $limit){ $txt1 = wordwrap($text, $limit, '[cut]'); $txt2 = explode('[cut]', $txt1); $ourTxt = $txt2[0]; $finalTxt = $ourTxt.$msg; }else{ $finalTxt = $text; } return $finalTxt; } return : The limited text description : It takes the text, add the string '[cut]' every $limit text by wordwrap, then we explode the text with '[cut]' and takes the first element in the array which we need ! how to use : wordCut($my_text, 200, '... read more'); EgypTechno ---- Server IP: 66.163.161.117 Probable Submitter: 196.202.69.2 ---- Manual Page -- http://www.php.net/manual/en/function.wordwrap.php Edit -- https://master.php.net/note/edit/70155 Del: integrated -- https://master.php.net/note/delete/70155/integrated Del: useless -- https://master.php.net/note/delete/70155/useless Del: bad code -- https://master.php.net/note/delete/70155/bad+code Del: spam -- https://master.php.net/note/delete/70155/spam Del: non-english -- https://master.php.net/note/delete/70155/non-english Del: in docs -- https://master.php.net/note/delete/70155/in+docs Del: other reasons-- https://master.php.net/note/delete/70155 Reject -- https://master.php.net/note/reject/70155 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#118068) next »