note 67132 added to function.strtoupper

From: Date: Sat, 03 Jun 2006 18:12:19 +0000
Subject: note 67132 added to function.strtoupper
Groups: php.notes 
Request: Send a blank email to php-notes+get-113137@lists.php.net to get a copy of this message
Angus Lord's function has got a problem with html entities such as &amp;, for they're converted into &Amp;, which is incorrect. The following code fixes the problem: <?php function to_upper($string) { $new_string = ""; while (eregi("^([^&]*)(&)(.)([a-z0-9]{2,9};|&)(.*)", $string, $regs)) { $entity = $regs[2].strtoupper($regs[3]).$regs[4]; if (html_entity_decode($entity) == $entity) $new_string .= strtoupper($regs[1]).$regs[2].$regs[3].$regs[4]; else $new_string .= strtoupper($regs[1]).$entity; $string = $regs[5]; } $new_string .= strtoupper($string); return $new_string; } ?> ---- Server IP: 217.174.203.10 Probable Submitter: 87.214.164.103 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.strtoupper.php Edit -- http://master.php.net/note/edit/67132 Del: integrated -- http://master.php.net/note/delete/67132/integrated Del: useless -- http://master.php.net/note/delete/67132/useless Del: bad code -- http://master.php.net/note/delete/67132/bad+code Del: spam -- http://master.php.net/note/delete/67132/spam Del: non-english -- http://master.php.net/note/delete/67132/non-english Del: in docs -- http://master.php.net/note/delete/67132/in+docs Del: other reasons-- http://master.php.net/note/delete/67132 Reject -- http://master.php.net/note/reject/67132 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#113137) next »