note 67132 deleted from function.strtoupper by hholzgra

From: Date: Thu, 02 Aug 2012 13:06:49 +0000
Subject: note 67132 deleted from function.strtoupper by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189704@lists.php.net to get a copy of this message
Note Submitter: sjrd at redaction-developpez dot com ---- 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; } ?>

« previous php.notes (#189704) next »