Answers for "php replace first occurrence in string"

PHP
0

php replace first occurrence in string

$pos = strpos($haystack, $needle);
if ($pos !== false) {
    $newstring = substr_replace($haystack, $replace, $pos, strlen($needle));
}
Posted by: Guest on October-04-2021

Code answers related to "php replace first occurrence in string"

Browse Popular Code Answers by Language