Replacing and Rewriting

str_replace($search, $replace, $subject, $count) replaces every occurrence and accepts arrays; str_ireplace() ignores ASCII case. substr_replace() overwrites a byte range, and strtr() translates single characters or, given an array, whole substrings. PHP 8.3's str_increment() and str_decrement() step alphanumeric counters, replacing ++ on non-numeric strings, which PHP 8.5 deprecates.

Templates, a word swap, masking and alphanumeric counters (replace.php)PHP
<?php
$tpl = 'Hello {name}, your {item} ships today.';
echo str_replace(['{name}', '{item}'], ['Ada', 'Dune'], $tpl), "\n";
echo str_ireplace('php', 'PHP', 'php is fun; Php is fast', $count), " ($count)\n";
$s = 'cats chase dogs';                             // swap two words
echo str_replace(['cats', 'dogs'], ['dogs', 'cats'], $s), ' | ',
    strtr($s, ['cats' => 'dogs', 'dogs' => 'cats']), ' | ', strtr('a-b_c', '-_', '  '), "\n";
echo substr_replace('4111111111111111', str_repeat('*', 12), 0, 12), ' ',
    str_increment('A9'), ' ', str_increment('Zz'), ' ', str_decrement('B0'), "\n";
Output
Hello Ada, your Dune ships today.
PHP is fun; PHP is fast (2)
cats chase cats | dogs chase cats | a b c
************1111 B0 AAa A9

str_replace() runs one pass per pair, so its second pass turned the new "dogs" back into "cats". strtr() scans once, tries the longest key first at each position and never revisits replaced text, which makes it the safe choice for placeholder templates.