PHP convert string to array

后端 未结 6 2006
南方客
南方客 2020-12-10 12:54

How can I convert a string to an array? For instance, I have this string:

$str = \'abcdef\';

And I want to get:

array(6) {
         


        
6条回答
  •  暖寄归人
    2020-12-10 13:34

    You can loop through your string and return each character or a set of characters using substr in php. Below is a simple loop.

    $str = 'abcdef';
    $arr = Array();
    
    for($i=0;$i

提交回复
热议问题