str_replace replaces all occurrences of a word with a replacement.
str_replace
preg_replace replaces occurrences of a pattern with a replacement and ta
preg_replace
Theres a better way to do this
$str = 'abcdef abcdef abcdef'; // pattern, replacement, string, limit echo preg_replace('/abc/', '123', $str, 1); // outputs '123def abcdef abcdef' ?>