pea_1 Posted April 24, 2007 Share Posted April 24, 2007 Hello, i'm trying to figure out how to put the characters of a string into an array, but i can't. Any ideas? Peter Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 24, 2007 Share Posted April 24, 2007 They already are (kindof)! $string = 'qwertyuiop'; echo $string{3}; // outputs e depends on what you need but if you truely need a proper bonefide array.. $string = trim('qwertyuiop'); $length = strlen($string); for($i=0; $i < $length; $i++) { if ($string{$i} != ' ') { arr[] = $string{$i}; } } Note: the if statement will make sure you only have characters in the array that are NOT spaces. Quote Link to comment Share on other sites More sharing options...
pea_1 Posted April 24, 2007 Author Share Posted April 24, 2007 Wow, never knew that. Thanks 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.