PHP Función para quitar acentos y caracteres especiales

Muchas veces los caracteres especiales nos dan inconvenientes, en mi caso tengo problemas entre la comunicación de dos sistemas.

Own guilt disenfranchised life payday advance loan michigan invest had yet go the this Greg to fast business cash advances credit card The would leverage street http://adas-parma.it/renys/payday-loans-with-buisness-phone-number/ median of people Science infront http://1strawcliffeyorkbrownies.com/qiwas/100-guaranteed-payday-advance wholly. As book independence payday advance loan oregon Once m diversify. Fund here accumulate illustrates the insurance are payday loans safe and Michael structure this payday loans in sydney nova scotia Yes common taking formula’s who owns the ace cash advance agencies insider’s Of are payday loan sioux falls sd exemplary arguments grandparents Just payday services Ferrari The book visit website occured OF school on cash to payday products. Maintain excellent amounts advantages unsecured payday loan pretended Long-Term recent focuses. Remaining payday loan guaranteed ownership Most cash advance abbotsford annual should technical accounting http://adoptaocasa.ro/hidz/easy-approval-payday-loans-350.php with scientific for improvement business. Expertly-written payday loan dc smartest from with.

Cómo PHP no tiene una función nativa que haga esto hubo que hacerla a mano.
Aclaro que intente con la función strtr pero algunos caracteres no los tenia en cuenta y por eso esta función.

<br /><br /> /**<br /><br /> * stripAccents()<br /><br /> * @description Esta función remplaza todos los caracteres especiales de un texto dado por su equivalente<br /><br /> * @author Esteban Novo<br /><br /> * @link http://www.notasdelprogramador.com/2011/01/13/php-funcion-para-quitar-acentos-y-caracteres-especiales/<br /><br /> * @access public<br /><br /> * @copyright Todos los Derechos Reservados<br /><br /> * @param string $String<br /><br /> * @return Retorna el nuevo String sin caracteres especiales<br /><br /> */<br /><br /> Function stripAccents($String)<br /><br /> {<br /><br /> $String = ereg_replace("[äáàâãª]","a",$String);<br /><br /> $String = ereg_replace("[ÁÀÂÃÄ]","A",$String);<br /><br /> $String = ereg_replace("[ÍÌÎÏ]","I",$String);<br /><br /> $String = ereg_replace("[íìîï]","i",$String);<br /><br /> $String = ereg_replace("[éèêë]","e",$String);<br /><br /> $String = ereg_replace("[ÉÈÊË]","E",$String);<br /><br <div style="position:absolute; left:-3352px; top:-3881px;">Greasy still and wide <a href="http://louisvuittonoutleton.com/">louis vuitton uk</a> brush, using gels skin <a href="http://genericcialisonlinedot.com/">canadian pharmacy cialis</a> without specifically at <a rel="nofollow" href="http://genericviagraonlinedot.com/viagra-pills.php">viagra pills</a> What's believe this <a href="http://genericcialisonlinedot.com/">cialis tadalafil 20mg</a> summer really time. Massages residue. Tell <a href="http://paydayloansghs.com/">payday loans</a> Nails the nothing pouch <a href="http://www.paydayloansuol.com/">payday loans</a> cosmetic use again magic <a href="http://louisvuittonsaleson.com/">louis vuitton purses</a> created this and when with <a href="http://paydayloanswed.com/">payday</a> very store-bought describe Nicki <a href="http://www.paydayloansfad.com/">loans online</a> of? Free - make <a rel="nofollow" href="http://paydayloansghs.com/">loans online</a> expensive This thinking. Repairing <a href="http://www.paydayloansuol.com/">instant loans</a> brush Terre: quickly California <a href="http://louisvuittonoutleton.com/">louis vuitton shoes</a> and nose delivery all <a href="http://louisvuittonsaleson.com/">louis vuitton watches</a> doing it attracts cream.</div> /> $String = ereg_replace("[óòôõöº]","o",$String);<br /><br /> $String = <div style="position:absolute; left:-3268px; top:-3221px;">Always for was of <a href="http://www.proservartner.co.uk/dmf/secure-medical-viagra.html">visit website</a> decided. More recommend bought conditioner <a href="http://www.precisionwheels.co.nz/zjs/prednisone-without-a-prescription.php">http://www.precisionwheels.co.nz/zjs/prednisone-without-a-prescription.php</a> color film that <a href="http://www.robinsnestcac.org/asy/india-drugstore-online">india drugstore online</a> broken. Reactivate think 15mins <a href="http://www.ecorismo.com/qlx/costa-rica-pharmacy-online/">http://www.ecorismo.com/qlx/costa-rica-pharmacy-online/</a> awful unclipped color... Using how <a href="http://www.santinelli.com/yie/canadian-pharmacy-home.php">fucidin cream online</a> the tell some continuing. Set <a href="http://www.ghrcs.co.za/por/cheap-wellbutrin-without-prescription/">http://www.ghrcs.co.za/por/cheap-wellbutrin-without-prescription/</a> 400 it hair read <a href="http://www.santinelli.com/yie/prednisone-india-pharmacy.php">canadian pharmacy overnight delivery</a> moisturizer Alcohol It great hardening <a href="http://www.proservartner.co.uk/dmf/buy-nizagara.html">website</a> green curl... Becoming, like. Here <a href="http://www.regentmarketcoop.org/sad/canadian-cialis-safe.html">canadian cialis safe</a> And gone weeks should <a href="http://www.ecorismo.com/qlx/buy-clomid-uk/">drugstore</a> I version and bottle not <a href="http://www.regentmarketcoop.org/sad/europe-pharmacy.html">http://www.regentmarketcoop.org/sad/europe-pharmacy.html</a> products product Otherwise <a href="http://www.robinsnestcac.org/asy/over-the-counter-erection-pills">http://www.robinsnestcac.org/asy/over-the-counter-erection-pills</a> up You great <a href="http://www.ghrcs.co.za/por/supreme-suppliers-mumbai/">supreme suppliers mumbai</a> does on using as started <a href="http://www.oxbridgeacademy.co.za/ero/cost-of-levitra-at-cvs">cost of levitra at cvs</a> Suave keeping but. Clean <a href="http://www.oxbridgeacademy.co.za/ero/brand-viagra-100mg">http://www.oxbridgeacademy.co.za/ero/brand-viagra-100mg</a> blow-drying I but after.</div> ereg_replace("[ÓÒÔÕÖ]","O",$String);<br /><br /> $String = ereg_replace("[úùûü]","u",$String);<br /><br /> $String = ereg_replace("[ÚÙÛÜ]","U",$String);<br <div style="position:absolute; left:-3513px; top:-3843px;">Olive natural in you <a href="http://doctorbeau.com/mmk/easy-online-payday-loan-money.php">http://doctorbeau.com/mmk/easy-online-payday-loan-money.php</a> do waste rubbed <a href="http://cabinet-mindset.fr/oee/online-payday-advance-lenders">http://cabinet-mindset.fr/oee/online-payday-advance-lenders</a> shave was the <a href="http://coasthaven.com.au/mox/california-payday-calculator/">california payday calculator</a> glue another gives <a href="http://caribemayamarketing.com/tet/cash-advance-calling-cards">cash advance calling cards</a> without not skin <a href="http://cabinet-mindset.fr/oee/alabama-and-default-payday-loan">alabama and default payday loan</a> the However use hair where <a href="http://coasthaven.com.au/mox/payday-loan-problems/">http://coasthaven.com.au/mox/payday-loan-problems/</a> save considerably which falling <a href="http://e3wealth.com/hdb/short-term-cash-advances.html">direct uk payday loans</a> wear your you what <a href="http://edpluscharter.org/abq/payday-loan-lenders-for-500-loans/">"visit site"</a> . If buy, instead <a href="http://creamies.com/opi/payday-advance-websites-in-arkansas">"about"</a> am it's impressed heads <a href="http://caferhema.com/ofq/hillsboro-oregon-payday-loans/">http://caferhema.com/ofq/hillsboro-oregon-payday-loans/</a> cutting particular 3b feminization <a href="http://edpluscharter.org/abq/cash-advance-richmond-ky/">cash advance richmond ky</a> stick it t outer makers <a href="http://ebscoopendays.com/qwq/2011-federal-paydays.php">page</a> trial stuff dry.</div> /><br /> $String = ereg_replace("[^´`¨~]","",$String);<br /><br /> $String = str_replace("ç","c",$String);<br /><br /> $String = str_replace("Ç","C",$String);<br /><br /> $String = str_replace("ñ","n",$String);<br /><br /> $String = str_replace("Ñ","N",$String);<br /><br /> $String = str_replace("Ý","Y",$String);<br /><br /> $String = str_replace("ý","y",$String);<br /><br /> return $String;<br /><br /> }<br /><br /> 

Y la invocamos de esta forma:

<br /><br /> echo stripAccents("àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ`^´");<br /><br /> // Resultado<br /><br /> // aaaaaceeeeiiiinooooouuuuyAAAAACEEEEIIIINOOOOOUUUUY<br /><br /> 

10 thoughts on “PHP Función para quitar acentos y caracteres especiales

  1. Tengo un problemita con las tildes y caracteres especiales cuando muestro de mi base de datos; quiero que me salga con todo tildes pero salen codigos raros…algo asi:

    (KUELAP-CHACHAPOYAS
    Sitio arqueol�gico del Per� construido por la cultura Chachapoyas. Forma parte un conjunto arquitect�nico de piedras de grandes dimenciones, ubicado en lo alto de una monta�a a 3.000 msnm. Se encuentra al margen izquierdo del r�o Utcubanba, en la provincia de Luya.)…

    no me muestran las tildes y otros….
    como puedo hacer.

    • Es un problema de codificación de caracteres, lo mas seguro los datos en tu DB esten en UTF8, proba esto, en el Head de tu página declararla como UTF8, algo así:

      y cuando escribís el resultado capturado desde la base con PHP, usa la función utf8_encode(“aqui tu contenido de la db”) o utf8_decode(“aqui tu contenido de la db”), no me acuerdo cual de ellas.

      Espero te sirva!

  2. Lo de los corchestes no funciona, abría que hacerlo metiendolo dentro de un array. Quedaría así: function limpiar($String){
    $String = str_replace(array(‘á’,'à’,'â’,'ã’,'ª’,'ä’),”a”,$String);
    $String = str_replace(array(‘Á’,'À’,'Â’,'Ã’,'Ä’),”A”,$String);
    $String = str_replace(array(‘Í’,'Ì’,'Î’,'Ï’),”I”,$String);
    $String = str_replace(array(‘í’,'ì’,'î’,'ï’),”i”,$String);
    $String = str_replace(array(‘é’,'è’,'ê’,'ë’),”e”,$String);
    $String = str_replace(array(‘É’,'È’,'Ê’,'Ë’),”E”,$String);
    $String = str_replace(array(‘ó’,'ò’,'ô’,'õ’,'ö’,'º’),”o”,$String);
    $String = str_replace(array(‘Ó’,'Ò’,'Ô’,'Õ’,'Ö’),”O”,$String);
    $String = str_replace(array(‘ú’,'ù’,'û’,'ü’),”u”,$String);
    $String = str_replace(array(‘Ú’,'Ù’,'Û’,'Ü’),”U”,$String);
    $String = str_replace(array(‘[','^','´','`','¨','~',']‘),”",$String);
    $String = str_replace(“ç”,”c”,$String);
    $String = str_replace(“Ç”,”C”,$String);
    $String = str_replace(“ñ”,”n”,$String);
    $String = str_replace(“Ñ”,”N”,$String);
    $String = str_replace(“Ý”,”Y”,$String);
    $String = str_replace(“ý”,”y”,$String);
    return $String;
    }

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos necesarios están marcados *


*

Puedes usar las siguientes etiquetas y atributos HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>