Convert a String into an Array of Characters

前端 未结 7 1257
陌清茗
陌清茗 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:40

    You can use the str_split() function

    $array = str_split($string);
    
    foreach ($array as $p){
    
        echo $p . "<br />";
    }
    
    0 讨论(0)
提交回复
热议问题