[Include] Explode
#1

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.
Reply
#2

Nice! - I think ****** did something like this though
Reply
#3

Nice.
Reply
#4

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...
Reply
#5

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

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

This is the same that sscanf.
Reply
#8

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.
Reply
#9

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.
Reply
#10

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!
Reply
#11

Wesites string library already includes similar function
Reply
#12

Nice script , thanks for likes!
Reply
#13

can someone reup this.
Reply
#14

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.
Reply
#15

Good work, mate.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)