AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Split at comma (https://forums.alliedmods.net/showthread.php?t=99348)

Rexonspix 08-04-2009 05:18

Split at comma
 
Hello

I need the following script to split a string up by the commas.

Etc:
Code:

new itemtotal[256] = "1,2,3,4,5,6,7,8,9,10";
new item1 .. item10;

split(itemtotal, item1, 0);
split(itemtotal, item2, 1);

Something like that :) ?
-Thanks

Alka 08-04-2009 05:44

Re: Split at comma
 
Something like...
PHP Code:

    new itemtotal[] = "1,2,3,4,5,6,7,8,9,10";
    
    new 
iNumszItem[10][6]; //Items 1,2,3,4...array start from 0.
    
while(contain(itemtotal",") != -1)
    {
        
strtok(itemtotalszItem[iNum++], charsmax(szItem), itemtotalcharsmax(itemtotal), ','); //Save each item.
    
}
    
copy(szItem[iNum], charsmax(szItem), itemtotal); //Save the last item "10" because don't have a comma after it. 


xPaw 08-04-2009 05:56

Re: Split at comma
 
replace , to space and parse?:0 just an idea..


All times are GMT -4. The time now is 18:24.

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