SA-MP Forums Archive
Mysql Explode Function - 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: Mysql Explode Function (/showthread.php?tid=576001)



Mysql Explode Function - nezo2001 - 31.05.2015

What is this xD
PHP код:
explode(const sSource[], aExplode[][], const sDelimiter[] = " "iVertices sizeof aExplodeiLength sizeof aExplode[]) // Created by Westie
{
    new
        
iNode,
        
iPointer,
        
iPrevious = -1,
        
iDelimiter strlen(sDelimiter);
    while(
iNode iVertices)
    {
        
iPointer strfind(sSourcesDelimiterfalseiPointer);
        if(
iPointer == -1)
        {
            
strmid(aExplode[iNode], sSourceiPreviousstrlen(sSource), iLength);
            break;
        }
        else
        {
            
strmid(aExplode[iNode], sSourceiPreviousiPointeriLength);
        }
        
iPrevious = (iPointer += iDelimiter);
        ++
iNode;
    }
    return 
iPrevious;




Re: Mysql Explode Function - dusk - 31.05.2015

First of all, this has nothing to do with 0.3.7.

This function splits a string by another string. For example if you have a string:
pawn Код:
string = "Hey, this is a string"
And use that function on it like so:
pawn Код:
new output[6][16];
explode(string, output, " ");
Will result in the array "output" values being:
pawn Код:
for(new i = 0; i < sizeof(output); i++)
    print(output[i]);
// Will print:
// Hey,
// this
// is
// a
// string