AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   about strings (https://forums.alliedmods.net/showthread.php?t=163191)

xfire 07-27-2011 16:28

about strings
 
how i detect a string how many times repeating in another string
Ex
fStr "alliedmodders" sStr "l"
there are two "l" in "alliedmodders" so it returns 2 value

i searched it but i couldnt find anything

Sylwester 07-27-2011 17:45

Re: about strings
 
PHP Code:

public cnt_substr(fStr[], sStr[]){
    new 
cntpostmp
    
new len strlen(sStr)
    new 
max strlen(fStr)-len+1
    
    
while(pos<max && (tmp contain(fStr[pos], sStr)) != -1){
        
pos += len+tmp
        cnt
++
    }
    return 
cnt




All times are GMT -4. The time now is 01:09.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.