SA-MP Forums Archive
strreplace problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: strreplace problem (/showthread.php?tid=582427)



strreplace problem - ShoortyFl - 20.07.2015

I'm having some trouble with str_replace from strlib include, so i wanted to replace @ with (at) when entering email but it's not working, and idk why,


pawn Код:
mysql_real_escape_string(inputtext, escinput);
                   
                    str_replace("@", "(at)", escinput);
                   
                    mysql_real_escape_string(inputtext, escinput);
                   
                    strcpy(PI[playerid][Email], escinput);
                   
                    TextDrawSetString(RegTD[playerid][8], escinput);



AW: strreplace problem - Kaliber - 20.07.2015

Use this code:

PHP код:
stock ReplaceString(const search[],const replace[], source[], size=sizeof source)
{
    new 
i=strfind(source,search),tmp=strlen(search),len=strlen(replace);
    if(
i==-1) return 0
    for( ; 
i!=-1i=strfind(source,search,false,i+len)) strdel(source,i,i+tmp),strins(source,replace,i,size);
    return 
1;

And do it like this:

PHP код:
ReplaceString("@""(at)"escinput);