-3

I'm using an api that's sending me url encoding like this:

https%3A%2F%2Fs3.amazonaws.com%2Fdocs.rightsignature.com%2Fassets%2...etc...

I can obviously see that %3A is likely : and %2F is / so that %3A%2F%2F resolves to ://.

My question is, how can I convert these in PHP. I am just not sure what to search for. Is there a function to convert these urls in PHP?

Maybe something like urldecode($thing).

Alexander Kleinhans
  • 5,950
  • 10
  • 55
  • 111

2 Answers2

2

You can use rawurldecode() for this.

echo rawurldecode("https%3A%2F%2Fs3.amazonaws.com%2Fdocs.rightsignature.com%2Fassets%2F"); // outputs https://s3.amazonaws.com/docs.rightsignature.com/assets/
Tim
  • 2,123
  • 4
  • 27
  • 44
2

Use urldecode($thing). It does work.

urldecode("https%3A%2F%2Fs3.amazonaws.com%2Fdocs.rightsignature.com%2Fassets..."); 
// https://s3.amazonaws.com/docs.rightsignature.com/assets...
Nicolapps
  • 819
  • 13
  • 29