View Single Post
  #2  
Old 07-09-2007, 11:54 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
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=0string.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.
Reply With Quote