tags:

views:

55

answers:

3

I have the following text:

We%27re%20proud%20to%20introduce%20the%20Amazing

I'd like to remove the encoding using PHP, but using html_entity_decode() does not work.

Any suggestions?

+1  A: 
echo urldecode('We%27re%20proud%20to%20introduce%20the%20Amazing');

This is an url_ecoded string. Use urldecode

erenon
A: 

%27 and %20 are URL encoded entities.

You'll want to use use urldecode() to decode this. urlencode() exists as well for encoding URL parameters.

jwhat
+2  A: 

This encoding is called Percent encoding or URL encoding. In PHP you have rawurlencode, rawurldecode for “raw” URL encoding as well as the urlencode and urldecode for the slightly different encoding that is used in the query (rather known as application/x-www-form-urlencoded where the space is encoded with + instead of %20).

In your case the “raw” URL encoding is used. So try rawurldecode to decode it:

rawurldecode('We%27re%20proud%20to%20introduce%20the%20Amazing')
Gumbo
+1 for rawurlencode/decode, but "rather known when using" means what?
Tchalvak