-1

How can i convert string like this

%C4%BE%C5%A1%C4%8D%C5%A5%C5%BE-%C3%BD%C3%A1%C3%AD%C3%A9

to this:

ľščťž-ýáíé

using PHP ?

Daniel Rossko Rosa
  • 362
  • 1
  • 2
  • 11

2 Answers2

2

Just use urldecode() function in php. Use the code below

<?php
$string = "%C4%BE%C5%A1%C4%8D%C5%A5%C5%BE-%C3%BD%C3%A1%C3%AD%C3%A9";
echo urldecode($string); // Outputs ľščťž-ýáíé
?>

Hope this helps you

Utkarsh Dixit
  • 4,267
  • 3
  • 15
  • 38
2

Just use urldecode() function, because you have url encoded string.

$encoded = '%C4%BE%C5%A1%C4%8D%C5%A5%C5%BE-%C3%BD%C3%A1%C3%AD%C3%A9';
$decoded = urldecode($encoded);
echo $decoded;

outputs:

ľščťž-ýáíé
Forien
  • 2,712
  • 2
  • 13
  • 30
  • I get output: ľščťž-ýáíé .. I am using codeigniter 2.2 and if i put this (ľščťž-ýáíé) in url, it auto change on this: (%C4%BE%C5%A1%C4%8D%C5%A5%C5%BE-%C3%BD%C3%A1%C3%AD%C3%A9) and urldecode() doesn't work.. I'm not that low, don't worry ;) – Daniel Rossko Rosa Feb 10 '15 at 14:06
  • 1
    @DanielRosskoRosa Are you using `charset="utf-8"` for html **and** `UTF-8 w/o BOM` for PHP files? You can also try to use `mb_internal_encoding("UTF-8")`. – Forien Feb 10 '15 at 14:09