Hi,
A fairly easy one I guess but whats the best way to split
ABCDEFG
so each char is on its own in the array?
String splitting with no spaces
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
it already is.
Code: Select all
for($i = 0; $i < strlen($str); $i++) {
echo str_repeat('-',$i).$str[$i]."\n";
}- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Strings are stored like "special" arrays anyway so this should work 
Code: Select all
$string = 'foobar';
$letters = array();
for ($x=0; $x<str_length($string); $x++)
{
$letters[] = $string{$x};
}
print_r($letters);