ssjskipp Posted May 14, 2006 Share Posted May 14, 2006 Okay, is there a way to explode, say:$a = "test";into an array of:$array = ["t", "e", "s", "t"]EDIT:Nevermind, I got it:"$chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);" Quote Link to comment Share on other sites More sharing options...
KrisNz Posted May 14, 2006 Share Posted May 14, 2006 str_split would be a bit faster. Quote Link to comment Share on other sites More sharing options...
ssjskipp Posted May 14, 2006 Author Share Posted May 14, 2006 [!--quoteo(post=373653:date=May 14 2006, 12:43 AM:name=KrisNz)--][div class=\'quotetop\']QUOTE(KrisNz @ May 14 2006, 12:43 AM) [snapback]373653[/snapback][/div][div class=\'quotemain\'][!--quotec--]str_split would be a bit faster.[/quote]it's plenty fast for what I need. Quote Link to comment Share on other sites More sharing options...
Barand Posted May 14, 2006 Share Posted May 14, 2006 You can treat a string as an array of characters[code]$a = 'test';for ($i=0; $i < 4; $i++){ echo $a{$i} . '<br>';}[/code]-->[code]test[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.