note 76083 added to function.wordwrap

From: Date: Fri, 29 Jun 2007 09:11:49 +0000
Subject: note 76083 added to function.wordwrap
Groups: php.notes 
Request: Send a blank email to php-notes+get-128075@lists.php.net to get a copy of this message
If your string has some html entities, then it might split one in half. e.g. <?php /* Outputs (Renders): Préf&- eacute;rence- s e-mails */ echo wordwrap("Pr&eacute;f&eacute;rences e-mails"); ?> To solve this, you can use the following function: <?php function wordwrap2( $str, $width = 75, $break = '\n', $cut = true ) { $str = html_entity_decode( $str ); //first decode $out = wordwrap( $str, $width, $break, $cut ); //now wordwrap $out = htmlentities( $out ); //re-encode the entities $out = str_replace( htmlentities( $break ), $break, $out ); //put back the break return $out; } ?> ---- Server IP: 194.145.210.4 Probable Submitter: 217.204.194.210 ---- Manual Page -- http://www.php.net/manual/en/function.wordwrap.php Edit -- https://master.php.net/note/edit/76083 Del: integrated -- https://master.php.net/note/delete/76083/integrated Del: useless -- https://master.php.net/note/delete/76083/useless Del: bad code -- https://master.php.net/note/delete/76083/bad+code Del: spam -- https://master.php.net/note/delete/76083/spam Del: non-english -- https://master.php.net/note/delete/76083/non-english Del: in docs -- https://master.php.net/note/delete/76083/in+docs Del: other reasons-- https://master.php.net/note/delete/76083 Reject -- https://master.php.net/note/reject/76083 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128075) next »