Hi Reader's,
Welcome to FindNerd, today we are going to discuss what is process to convert string into an array using PHP ?
If you want to convert a string into a array then you should use str_split() function
let us know how it is works ?
The str_split() function is used to split a string into an array.
syntax of str_split() function
str_split(string,length)
In above syntax string parameter is necessary and length is optional parameter
you can see bellow example with string parameter only
<?php
//here call str_split() and pass string
print_r(str_split("Jorden"));
?>
output will come of following above
Array ( [0] => J [1] => o [2] => r [3] => d [4] => e [5] => n )
And now you can see bellow example with string parameter and length
<?php
//here call str_split() and pass string
print_r(str_split("Jorden",3));
?>
output will come of following above
Array ( [0] => Jor [1] => den )
0 Comment(s)