0

Let's say i have a string like this: "Sóc Trăng".

What i want to do is check whether ó and ă exist in the string "Sóc Trăng". If those two letters exist in the string, I want to replace ó with o and ă with a.

How can i do so in php?

Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
CloudSeph
  • 863
  • 4
  • 15
  • 36

2 Answers2

3

Simply use str_replace for it

$str = "Sóc Trăng";
echo str_replace( array('ó', 'ă'), array('o', 'a'), $str);

output

Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
0

You can do something like this

$str = "Sóc Trăng";
str_replace("ó","o",$str);
str_replace("ă","a",$str);

Thats it.