note 85431 deleted from function.str-replace by philip

From: Date: Wed, 07 Oct 2009 07:59:58 +0000
Subject: note 85431 deleted from function.str-replace by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-161450@lists.php.net to get a copy of this message
Note Submitter: marco dot carvalho at onda dot com dot br ---- If you need to replace áóíóú and other special char, you need encondig type suport. For this, just use htmlentities and some regular expressions <?PHP function RemoveAcentos($str, $enc = "UTF-8"){ $acentos = array( 'A' => '/&Agrave;|&Aacute;|&Acirc;|&Atilde;|&Auml;|&Aring;/', 'a' => '/&agrave;|&aacute;|&acirc;|&atilde;|&auml;|&aring;/', 'C' => '/&Ccedil;/', 'c' => '/&ccedil;/', 'E' => '/&Egrave;|&Eacute;|&Ecirc;|&Euml;/', 'e' => '/&egrave;|&eacute;|&ecirc;|&euml;/', 'I' => '/&Igrave;|&Iacute;|&Icirc;|&Iuml;/', 'i' => '/&igrave;|&iacute;|&icirc;|&iuml;/', 'N' => '/&Ntilde;/', 'n' => '/&ntilde;/', 'O' => '/&Ograve;|&Oacute;|&Ocirc;|&Otilde;|&Ouml;/', 'o' => '/&ograve;|&oacute;|&ocirc;|&otilde;|&ouml;/', 'U' => '/&Ugrave;|&Uacute;|&Ucirc;|&Uuml;/', 'u' => '/&ugrave;|&uacute;|&ucirc;|&uuml;/', 'Y' => '/&Yacute;/', 'y' => '/&yacute;|&yuml;/', 'a.' => '/&ordf;/', 'o.' => '/&ordm;/' ); return preg_replace($acentos, array_keys($acentos), htmlentities($str,ENT_NOQUOTES, $enc)); } ?>

« previous php.notes (#161450) next »