note 85431 added to function.str-replace

From: Date: Fri, 29 Aug 2008 18:54:34 +0000
Subject: note 85431 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-143989@lists.php.net to get a copy of this message
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)); } ?> ---- Server IP: 200.185.109.13 Probable Submitter: 189.34.120.241 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- https://master.php.net/note/edit/85431 Del: integrated -- https://master.php.net/note/delete/85431/integrated Del: useless -- https://master.php.net/note/delete/85431/useless Del: bad code -- https://master.php.net/note/delete/85431/bad+code Del: spam -- https://master.php.net/note/delete/85431/spam Del: non-english -- https://master.php.net/note/delete/85431/non-english Del: in docs -- https://master.php.net/note/delete/85431/in+docs Del: other reasons-- https://master.php.net/note/delete/85431 Reject -- https://master.php.net/note/reject/85431 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143989) next »