SA-MP Forums Archive
[Include] Explode - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] Explode (/showthread.php?tid=223561)



Explode - Pghpunkid - 09.02.2011

Explode
By Pghpunkid

Description
This function does the same as the one you would find in PHP.

Examples
pawn Code:
new newload[10][32];
explode("This is a string"," ",newload);
printf("%s-%s-%s-%s",newload[0],newload[1],newload[2],newload[3]);
This would output:
pawn Code:
This-is-a-string
--
pawn Code:
new newload[10][32];
explode("/command Integer string goes here."," ",newload,2);
printf("%s-%s-%s",newload[0],newload[1],newload[2]);
This would output:
pawn Code:
/command-Integer-string goes here
Parameters
explode(string[],delim[],result[][],maxsplit=0)

string[] - Your string you wish to explode.
delim[] - a string of which you wish to split your string up by. (Think of it as where you need to break it.)
result[][] - 2-Dimensional array, where the result will be stored.
maxsplit - Number of times you want to break the string. (Optional)

There are 2 more, but they are just fail-safes and get the sizes of result to prevent buffer overflow.

Notes
This is only 1 function, 1 include.. however i feel it deserves to be an include, otherwise it will be like strtok where you constantly have to hunt through old scripts to copy/paste the function.

Download Include and Filterscript

This was an idea i came up with in the shower.. i come up with some of my best ideas there.

Thanks for helping Slice.


Re: Explode - Ash. - 09.02.2011

Nice! - I think ****** did something like this though


Re: Explode - TheAlienForce - 09.02.2011

Nice.


Re: Explode - Pghpunkid - 09.02.2011

I wasn't sure if anyone has. Either way, its out there. Its not an arms race.

EDIT: Ohhh it was in YSI.. no wonder i never saw it...


Re: Explode - RyDeR` - 09.02.2011

Thanks for sharing, though this is just a simple split function isn't it?


Re: Explode - Pghpunkid - 09.02.2011

Yep. You can split a string into seperate segments based on a delimiter.


Respuesta: Explode - anonymousx - 11.02.2011

This is the same that sscanf.


Re: Explode - Pghpunkid - 11.02.2011

I dont know enough about sscanf to know what the differences are, but i am pretty sure sscanf uses a plugin. This would eliminate the need for a plugin if that is true.


Re: Explode - Calgon - 11.02.2011

sscanf isn't the same as this, this splits by a delimiter and has no additional usage for parameters to split by (like sscanf does). This is just a port for the explode function.

Westie already released an include/library for PHP-like string manipulation, you should have probably released this in the 'useful functions' thread seeing as it's merely a function.

Good work, nevertheless.


Re: Explode - Pghpunkid - 11.02.2011

Quote:

you should have probably released this in the 'useful functions' thread seeing as it's merely a function.

Yeah i address that in the OP.. but i like it when other people telling me bad things about my releases. Its pretty fun.

Thanks Calgon. Appreciated!


Re: Explode - iMonk3y - 11.02.2011

Wesites string library already includes similar function


Re: Explode - [M.A]Angel[M.A] - 11.02.2011

Nice script , thanks for likes!


Re: Explode - Donya - 05.07.2011

can someone reup this.


Re: Explode - Pghpunkid - 05.09.2011

Quote:
Originally Posted by Donya
Посмотреть сообщение
can someone reup this.
Just get Westies PHP String stuff. It has more included functions for string manipulation like explode and others.

I CBF to upload atm, and im about to take off to the other side of the world.. again.


Respuesta: Re: Explode - CTCCoco - 31.07.2012

Good work, mate.