PHP - iterate on string characters

前端 未结 9 850
失恋的感觉
失恋的感觉 2020-12-04 14:01

Is there a nice way to iterate on the characters of a string? I\'d like to be able to do foreach, array_map, array_walk, array_

9条回答
  •  情深已故
    2020-12-04 14:23

    Expanded from @SeaBrightSystems answer, you could try this:

    $s1 = "textasstringwoohoo";
    $arr = str_split($s1); //$arr now has character array
    

提交回复
热议问题