View difference between Paste ID: n4F0HHxT and ywEMLnz7
SHOW: | | - or go back to the newest paste.
1
stock str_replace(_string[], _substr[], _substr_rp[])
2
{
3-
	new _len = strlen(_substr), _len2 = strlen(_string);
3+
	new _len = strlen(_substr), _len2 = strlen(_string), lastreplace;
4-
	for(new x = strfind(_string, _substr); x!= -1; x = strfind(_string, _substr))
4+
	for(new x = strfind(_string, _substr); (x!= -1  || x<= lastreplace) ; x = strfind(_string, _substr))
5
	{
6
		strdel(_string, x, x+_len);
7
		strins(_string, _substr_rp, x);
8
		lastreplace = x;
9
	}
10
	return 1;
11
}