PHP convert string to array

后端 未结 6 2012
南方客
南方客 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:19

    Note that starting with php 5.5 you can refer to string characters by array indices, which in most cases prevents need for the solution(s) above.

    $str = 'abdefg';
    echo $str[4]; // output: f
    

提交回复
热议问题