How to convert a string to an array of it's characters in PHP?

October 26, 2018

If you want to get an array of (single) letters from a string, it is easy in PHP! Here is how to do it:

Use str_split() to get a text string's characters as an array

<?php
$input = "abcdef";
$array = str_split($input); // ['a','b','c','d','e','f']