PHP Convert to Array
To split a string into an array using a specified
delimiter, the explode function is used.
See the example:
<?php
$str = 'ab-cd-e';
$arr = explode('-', $str);
var_dump($arr);
?>
Code execution result:
['ab', 'cd', 'e']
To convert a string to an array, the
str_split function is used.
See the example:
<?php
$str = 'abcde';
$arr = str_split($str, 2);
var_dump($arr);
?>
Code execution result:
['ab', 'cd', 'e']