note 80643 added to function.wordwrap

From: Date: Sun, 27 Jan 2008 01:35:02 +0000
Subject: note 80643 added to function.wordwrap
Groups: php.notes 
Request: Send a blank email to php-notes+get-135431@lists.php.net to get a copy of this message
This function will provide word-wrap functionality to Firefox (most other browsers have a CSS alternative) by using a zero-width character between every character of any word that goes past the limited size. <?php /** * @desc Wraps a string using a zero-width character between each character of any word past the size limit. * @param string String to wrap * @param int Word length limit * * @return string Cut string */ function cut_word($txt, $where=12) { if (empty($txt)) return false; for ($c = 0, $a = 0, $g = 0; $c<strlen($txt); $c++) { $d[$c+$g]=$txt[$c]; if ($txt[$c]!=" ") $a++; else if ($txt[$c]==" ") $a = 0; if ($a>$where) { $g++; $d[$c+$g]="&#8203;"; } } return implode("", $d); } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 172.216.80.130 ---- Manual Page -- http://www.php.net/manual/en/function.wordwrap.php Edit -- https://master.php.net/note/edit/80643 Del: integrated -- https://master.php.net/note/delete/80643/integrated Del: useless -- https://master.php.net/note/delete/80643/useless Del: bad code -- https://master.php.net/note/delete/80643/bad+code Del: spam -- https://master.php.net/note/delete/80643/spam Del: non-english -- https://master.php.net/note/delete/80643/non-english Del: in docs -- https://master.php.net/note/delete/80643/in+docs Del: other reasons-- https://master.php.net/note/delete/80643 Reject -- https://master.php.net/note/reject/80643 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135431) next »