Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php replace first occurrence in string

$pos = strpos($haystack, $needle);
if ($pos !== false) {
    $newstring = substr_replace($haystack, $replace, $pos, strlen($needle));
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #replace #occurrence #string
ADD COMMENT
Topic
Name
2+3 =