note 116551 deleted from function.strtr by salathe

From: Date: Fri, 06 Feb 2015 12:56:46 +0000
Subject: note 116551 deleted from function.strtr by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-201603@lists.php.net to get a copy of this message
Note Submitter: wissamelkik at gmail dot com ---- I was using the following function to normalize a string. The function strtr wasn't working. I had to add a header with charset: ISO-8859-1 to make it work. PS: I had to reduce the size of the array to be able to post this note. <?php header("Content-Type: text/plain; charset=ISO-8859-1"); function normalizeChars($s) { $replace = array( '&amp;' => 'and', '@' => 'at', '©' => 'c', '®' => 'r', 'À' => 'a', 'Á' => 'a', 'Â' => 'a', 'Ä' => 'a', 'Å' => 'a', 'Æ' => 'ae','Ç' => 'c', 'È' => 'e', 'É' => 'e', 'Ë' => 'e', 'Ì' => 'i', 'Í' => 'i', 'Î' => 'i', 'Ï' => 'i', 'Ò' => 'o', 'Ó' => 'o', 'Ô' => 'o', 'Õ' => 'o', 'Ö' => 'o', 'Ø' => 'o', 'Ù' => 'u', 'Ú' => 'u', 'Û' => 'u', 'Ü' => 'u', 'Ý' => 'y', 'ß' => 'ss','à' => 'a', 'á' => 'a', 'â' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'ae','ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'ñ' => 'n', ); return strtr($s, $replace); } $str = '<?xml version="1.0" encoding="ISO-8859-1"?><data><id><![CDATA[5531]]></id><baños><![CDATA[0]]></baños></data>'; echo normalizeChars($str); ?>

« previous php.notes (#201603) next »