In my project I get back a name of a person through a php response. And I store that name in a variable.
So the name could be like James Smith or Sakhu Ali Khan or anything else.
I want to replace the spaces between the names with “.”
Suppose I get the James Smith and I will save it in $userName
Now I want to parse $userName and then replace the spaces with “.” so my
$parsedUserName == James.Smith
Can anyone tell me how to do this in php. I am not very much familiar with text parsing.
Best
Zeeshan
You can use the
str_replace()function to do this:If you’re using UTF-8 or another multibyte character set then you should use
mb_str_replace()instead.