I want to explode a string into an array where all of the letters are a value to the array...
Let's say I have the following string for example...
$str = "abs12fg";
I want that to become equivalent to
array('a', 'b', 's', '1', '2', 'f', 'g');
I've tried explode('', $str); & split()lbut that doesn't help... thanks.
explode a string
Moderator: General Moderators
Re: explode a string
Try str_split instead.
- Skoalbasher
- Forum Contributor
- Posts: 147
- Joined: Thu Feb 07, 2008 8:09 pm
Re: explode a string
I'm pretty sure explode doesn't work like that. Explode needs something to seperate.dheeraj wrote:I want to explode a string into an array where all of the letters are a value to the array...
Let's say I have the following string for example...
$str = "abs12fg";
I want that to become equivalent to
array('a', 'b', 's', '1', '2', 'f', 'g');
I've tried explode('', $str); & split()lbut that doesn't help... thanks.
Code: Select all
$str = "a,b,c,d,e,f,g";
$strex = explode(",", $str);
print_r($strex);