In PHP, how do i convert:
$result = abdcef;
into an array that's:
$result[0] = a;
$result[1] = b;
$result[2] = c;
$result[3] = d;
In PHP, how do i convert:
$result = abdcef;
into an array that's:
$result[0] = a;
$result[1] = b;
$result[2] = c;
$result[3] = d;
You will want to use str_split().
http://us2.php.net/manual/en/function.str-split.php
best you should go for "
str_split()
", if there is need to manual Or basic programming,Output:
You can use the
str_split()
functionThere is also an optional parameter on the str_split function to split into chunks of x characters.
Don't know if you're aware of this already, but you may not need to do anything (depending on what you're trying to do).
So you can access it like an array without any faffing if you just need something simple.
With the help of str_split function, you will do it.
Like below::