regex - How to FULLY replace all special characters in PHP wihtout leaving any HTML Entity in the result -


i need php replace function trying create.

basically, want fylly convert special characters á, é, í, ó, ú, ü, ñ, Á, É, Í, Ó, Ú, Ü, Ñ , on this: a, e, i, o, u, u, n, a, e, i, o, u, u, n. below explained why "fully convert".

now have managed half way using below function:

function clean_url($text){          $text = preg_replace('~&([a-z]{1,10})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($text, ent_quotes, 'utf-8'));     return $text; } 

this @ first glance gives me desired result when viewed in mysql or browser, in php:

$string = "Ábalos"; echo clean_url($string); 

html page source code output: abalos. right @ first glance.

but when

$string = "Ábalos"; echo htmlentities(clean_url(($string)); 

html page source code output: aâ?balos.

i want able replace function part â?. how can achieved?

i found function (in thread : how remove accents , turn letters "plain" ascii characters?) :

function toascii( $str ) {     return strtr(utf8_decode($str),          utf8_decode(         'ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ'),         'sozsozyyuaaaaaaaceeeeiiiidnoooooouuuuysaaaaaaaceeeeiiiionoooooouuuuyy'); } 

i tested strings , works. example :

function toascii( $str ) {     return strtr(utf8_decode($str),          utf8_decode(         'ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ'),         'sozsozyyuaaaaaaaceeeeiiiidnoooooouuuuysaaaaaaaceeeeiiiionoooooouuuuyy'); }  $string = "Ábalos";  echo toascii($string); 

will print abalos


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -