Convert a String into an Array of Characters

前端 未结 7 1267
陌清茗
陌清茗 2020-11-29 08:05

In PHP, how do I convert:

$result = "abdcef";

into an array that\'s:

$result[0] = a;
$result[1] = b;
$result[2] = c;         


        
7条回答
  •  悲&欢浪女
    2020-11-29 08:20

    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.

提交回复
热议问题