1

Im using the function get_query_var() to retrive my url path.

My url path looks like: /categories/500-Beställning

Now to retrieve this I use:

$url = get_query_var('title2');

If I var_dump($url); I get: string(29) "500-Best%C3%A4llning".

Now the letter ä is encoded. I have tried the function utf8_decode, which did not work, to decode it. But I am not quite sure to what is is encoded and how to correctly decode it. Thanks!

mrfr
  • 1,724
  • 2
  • 23
  • 44
  • `utf8_decode` "Converts a string with ISO-8859-1 characters encoded with UTF-8 to single-byte ISO-8859-1". You aren't dealing with character encoding issues here. – Quentin Jan 02 '18 at 11:24
  • @Quentin Yea, I figuerd it was that. `urldecode()` worked perfectly. Will accept your answer as soon as i can! – mrfr Jan 02 '18 at 11:28

1 Answers1

3

To decode URL encoded data, use urldecode:

<?php
  $string = "500-Best%C3%A4llning";
  print urldecode($string);
?>
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335