phputf-8asciifarsi

How to get persian/arabic characters from url and then show it


I have coded this:

$url = "https://sitename.com/product-category/کتگوری";
$parsed = parse_url($url);
$path = $parsed['path'];
$path_parts = explode('/', $path);
$desired_output = $path_parts[2]; 
echo $desired_output;

Now the returned result is this: %d8%a2%d9%86

Which is referring to کتگوری but does not show up correctly.

So I need to show the $desired_output correctly in persian/arabic characters.

How to do this?


Solution

  • echo rawurldecode($desired_output);