╰┈➤ The str_replace() function replaces some characters with some other characters (together) in a string. For example :
$test = "Hello world";
echo str_replace("world", "Valer", $test);
// outputs: Hello Valer
► str_replace() is a more global approach to replacements, while
strtr() simply translates the characters ONE BY ONE.
// therefore if we use that function instead of str_replace at that case, it outputs differently. ◄
$test2 = "Hello world";
echo strtr($test2, "world", "Valer");
// outputs: Heeea Valer
// because it translated l > e, o > a. (w > V, r > l, d > r)
by Luka Khitaridze
2 years ago
PHP
Functions
0
Pro tip: use ```triple backticks around text``` to write in code fences