How to convert special characters?

1

I have a search system, but it does not respond very well with special characters like: ç , ã , á , ô , etc.

So, I want the input user to type, for example: "Union" and that GET['nome'] exits more or less like this: Uni%C3%A3o .

I've tried using htmlspecialchars but nothing happens!

The motio is, the search is in the SuperCell API Clash of Clans developer, and the search only succeeds when special characters are in that format!

    
asked by anonymous 29.10.2016 / 20:41

1 answer

3

Use the urlencode function:

$string = "União";
echo htmlentities(urlencode($string)); // Uni%C3%A3o
    
29.10.2016 / 20:51