| Twinny |
07-09-2007 11:54 AM |
I'm not sure if there is a function to split a string into an array by characters. I made an example one for you.
PHP Code:
function onCreated() { this.string = "Splitting a string by characters"; temp.array = splitstring(this.string); echo(temp.array); }
function splitstring(string) { for (t=0; t < string.length(); t++) { if (string.substring(t,1) != " ") { temp.array.add(string.substring(t,1)); } } return temp.array; }
Echo'd 'S,p,l,i,t,t,i,n,g,a,s,t,r,i,n,g,b,y,c,h,a,r,a,c,t ,e,r,s'. I didn't add spaces by default but you can change that if need be. Hope this helps.
|