Stian Stian - 1 year ago 71
PHP Question

How to replace certain parts of my string?

How can I replace a certain part of my string with another one?

Input string:

Hello my name is Santa"

Now how can I change all
's in my string with something else?

I think I need a
loop, but I'm unsure how to use it.

Answer Source
strtr ($str, array ('a' => '<replacement>'));


strtr ("hello my name is santa", array ('a' => '<replacement>'));

To answer your question more precisely.