Reputation: 3707
I have i string in my PHP-code which looks like this
Bokad av Anna Göransson 14:45 - 15:45
Now i want to replace "Anna" with "A.". How can i do that using regexp and PHP?
Upvotes: 0
Views: 192
Reputation:
You can do use something like this
$foo=str_replace('Anna', 'A',$foo);
Upvotes: 0
Reputation: 81731
You can use something different if the string is dynamic and subject to change.
$string = "okad av Anna Göransson 14:45 - 15:45";
$names = explode(" ",$string);
$names[2] = strtoupper($names[2][0]).".";
$string = implode(" ",$names);
Upvotes: 2