0

how can I decode following query string with php?

t=%B1Z%2B%26k%C9%BF%B1%3Fh%3Fd%3F%9F%2Fa%90%3Ft%C5%8B%A0%3F-%F9s%D5d+%E2sJ-B%9DE%D0T%FA%A4.%93%AF%A05%98d%F9%85%CC%22H%3Fd%F9%9D%C3%22hE%8B%C1%D65%3F%A8%3A%25%24&charset=ISO-8859-1

I've already tried urldecode but I get following output

t=±Z+&kÉ¿±?h?d?Ÿ/a?tÅ‹ ?-ùsÕd âsJ-BEÐTú¤.“¯ 5˜dù…Ì"H?dùÃ"hE‹ÁÖ5?¨:%$&charset=ISO-8859-1

I've tried many ways but couldn't decode it

thanks in advance

hakre
  • 193,403
  • 52
  • 435
  • 836
qwera
  • 185
  • 1
  • 1
  • 11
  • 4
    try: url_decode() - http://php.net/manual/en/function.urldecode.php – Book Of Zeus Dec 17 '11 at 23:03
  • 1
    possible duplicate of [How to decode the url in php where url is encoded with encodeURIComponent()](http://stackoverflow.com/questions/2757911/how-to-decode-the-url-in-php-where-url-is-encoded-with-encodeuricomponent) – Gordon Dec 17 '11 at 23:04

4 Answers4

2

Use parse_str to "decode" and parse your string, as in the example snippet further down in this post.

Read more about the function in php.net's manual:


$data = "t=%B1Z%2B%26k%C9%BF%B1%3Fh%3Fd%3F%9F%2Fa%90%3Ft%C5%8B%A0%3F-%F9s%D5d+%E2sJ-B%9DE%D0T%FA%A4.%93%AF%A05%98d%F9%85%CC%22H%3Fd%F9%9D%C3%22hE%8B%C1%D65%3F%A8%3A%25%24&charset=ISO-8859-1";

parse_str ($data, $out);
print_r   ($out);

Array
(
    [t] => ±Z+&kÉ¿±?h?d?/a?tÅ ?-ùsÕd âsJ-BEÐTú¤.¯ 5dùÌ\"H?dùÃ\"hEÁÖ5?¨:%$
    [charset] => ISO-8859-1
)
Filip Roséen - refp
  • 62,493
  • 20
  • 150
  • 196
0

maybe this one might help:

<?php
$variable = 'http%3A%2F%2Fsample.com';
$variable = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($variable)); 
$variable = html_entity_decode($variable,null,'UTF-8');
echo $variable;
?>

output will be : http://sample.com

T.Todua
  • 53,146
  • 19
  • 236
  • 237
0

Read about urlencode and urldecode here

$output = urldecode($encoded);
SlavaNov
  • 2,447
  • 1
  • 18
  • 26
0

Use urldecode!

$decoded = urldecode(substr($queryString,3));
Alex
  • 32,506
  • 16
  • 106
  • 171