|
Post by James :) (aka Madcow) on Aug 20, 2008 4:22:10 GMT -5
Built in split and join commands
|
|
|
Post by Nicky Peter Hollyoake on Aug 20, 2008 4:31:21 GMT -5
What they do?
|
|
|
Post by James :) (aka Madcow) on Aug 20, 2008 6:51:18 GMT -5
split splits a string into an array. so split("hi,bob", ",") would crete an array with 2 items "hi" and "bob" and split("hi,bob", "b") would crete an array with 2 items "hi," and "o".
join is the reverse it would take all the arrays items and join them into an string.
|
|
|
Post by andrian on Aug 20, 2008 8:05:59 GMT -5
I sorta get what you're saying, except for split("Hi,bob", "b". that explanation made no real sense to me. what did I miss?
|
|
|
Post by James :) (aka Madcow) on Aug 20, 2008 12:38:22 GMT -5
ok heres split explained better, say we have a list of months with commas divding them:
"january, febuary, march, april, etc"
and say we wanted to take the list and put it into an array.
first we dim the array and make the array equal the split function
[b]dim a(12) = split()[/b]
then we pass the string we want to split into the first parameter
dim a(12) = split([b]"january, febuary, march, april, etc"[/b])
the next thing we want to do is define the char the function splits by as our second parameter.
dim a(12) = split("january, febuary, march, april, etc",[b] ","[/b])
so what this does is the function takes our string and starts at array index 0 or in this case a(0) ,it continues thoughtour string untill it reaches a char that is the same as the one in our second parameter in our case we defined it as "," then it stores all the string before the "," into array index 0 or a(0) then it moves onto array index 1 or a(1).
in our example if we were to print out the array made by the split function it would produce all of our dates each in an diffrent postion in the array with the commas taken out.
so a(0) would equal "january" and a(12)="december".
|
|
|
Post by James :) (aka Madcow) on Aug 22, 2008 16:33:44 GMT -5
make any more sense ?
|
|
|
Post by andrian on Sept 9, 2008 10:34:53 GMT -5
yup, now I get it. Sounds useful, but wouldn't this be more something to put in a plugin?
|
|