Reputation: 1390
I have $String1 which I know has the value 999 and is 3 digits and starts at pos 7 in $String2.
$String1 = 999;
$String2 = 789992399987;
I would like to eliminate $String1 from $String2, to create $String3
$String3 = 789992387;
I don't think I can use strstr, because as in this case 999 appears 0,1 or more times before the string I want to eliminate
My current work around is the unelegant way of making $String2 an array and because I know the position and length of $String1 unset those keys.
Upvotes: 0
Views: 152
Reputation: 47776
If you want to remove a substring from a string by position and length, you can use substr_replace
.
$String3 = substr_replace($String2, '', 7, 3);
http://codepad.viper-7.com/ttQhvA
Upvotes: 3