-1

How can I escape 'special chars' in PHP, regardless of in which enc-type they are? Like so:

INPUT: ë, ë

OUTPUT: e, e

I hope someone can help. Thanks in advance!

user1806756
  • 145
  • 1
  • 2
  • 11

2 Answers2

-1

Try starting with this:

function replace_accents($str) {
   $str = htmlentities($str, ENT_COMPAT, "UTF-8");
   $str = preg_replace('/&([a-zA-Z])(uml|acute|grave|circ|tilde);/','$1',$str);
   return html_entity_decode($str);
}

This function will convert all the accented chars into normal ones.

Jazzpaths
  • 645
  • 5
  • 9
-1

did some quick coding for this.

<?php 

function correctWord($val) {
    return iconv('UTF-8','ASCII//TRANSLIT', html_entity_decode($val));
}

echo correctWord("ë, &euml;");

found the fix in accented character from this Replacing accented characters php

KevDev
  • 541
  • 2
  • 6
  • 20
  • 2
    ... doesn't that basically make this question a duplicate? Should you not have just voted to close instead of answering? – CD001 Jan 20 '20 at 15:10
  • i think its not duplicate since this question is asking for the special character. and other is replacing accented characters. – KevDev Jan 20 '20 at 15:15