Alex Rivera | Logout

Convert a String into an Array of Characters

Asked 2010-05-04T19:21:07.817
65

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;

Edited

Edit
Report

1 Answer

32

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).

$string = "abcdef";
echo $string[1];
//Outputs "b"

So you can access it like an array without any faffing if you just need something simple.

answered 2010-05-04T20:42:23.787

Your Answer