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

Time:05-28

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: آن

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?

CodePudding user response:

echo rawurldecode($desired_output);
  • Related