Stian Stian - 2 years ago 89
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
a
's in my string with something else?

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

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

UPDATE:

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

To answer your question more precisely.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download