Is there a PHP function that can do that?
I'm using strpos
to get the position of a substring and I want to insert a string
after that position.
Is there a PHP function that can do that?
I'm using strpos
to get the position of a substring and I want to insert a string
after that position.
$newstr = substr_replace($oldstr, $str_to_insert, $pos, 0);
In the above snippet, $pos
is used in the offset
argument of the function.
offset
If offset is non-negative, the replacing will begin at the offset'th offset into string.If offset is negative, the replacing will begin at the offset'th character from the end of string.