2

I'm having trouble replacing a single quote in a string, the purpose is to create part of an URL

For example : If I type in "Villeneuve d'ascq" I would want to have :

Villeneuve+d%27ascq", %27 being the ascii equivalent of (')

I tried using str_replace("'", ord("'"), string_name) but it doesn't seem to work

Any help would be appreciated and feel free to ask for any more details

Rotimi
  • 4,783
  • 4
  • 18
  • 27
Rémy.W
  • 225
  • 2
  • 9

1 Answers1

1

Please try this :

echo '<a href="test.com', urlencode(."Villeneuve d'ascq".), '">test</a>';

You can also check this at : PHP MANUAL

vikalp
  • 330
  • 2
  • 9
  • 1
    Sorry but this is not a question that needs an answer. These types of questions should be marked as duplicate. Also it was resolved in a manner that it won't help any future readers. – Aniket Sahrawat Mar 14 '18 at 09:24