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);" Link to comment https://forums.phpfreaks.com/topic/9637-explode-help/ Share on other sites More sharing options...
KrisNz Posted May 14, 2006 Share Posted May 14, 2006 str_split would be a bit faster. Link to comment https://forums.phpfreaks.com/topic/9637-explode-help/#findComment-35621 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. Link to comment https://forums.phpfreaks.com/topic/9637-explode-help/#findComment-35623 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] Link to comment https://forums.phpfreaks.com/topic/9637-explode-help/#findComment-35658 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.