Bernat
Bernat

Reputation: 1556

Process percent-encoded string with special characters in PHP

I got an string like:

M%C3%B2nica

So I need to get something like "Mònica".

Which is the best way in PHP?

Upvotes: 4

Views: 1206

Answers (2)

ilanco
ilanco

Reputation: 9967

Shortest answer : urldecode();

Upvotes: 1

Jeroen
Jeroen

Reputation: 13257

echo rawurldecode ('M%C3%B2nica'); // prints Mónica

You can either use urldecode() or rawurldecode(), but in your case it probably doesn't make a difference. (read more on this here: urlencode vs rawurlencode?)

Upvotes: 9

Related Questions