How to convert a string to an array in PHP?

In PHP, you can use the str_split() function to convert a string into an array. Here is an example code:

$string = "Hello World";
$array = str_split($string);

print_r($array);

Running the above code will produce the following output:

Array
(
    [0] => H
    [1] => e
    [2] => l
    [3] => l
    [4] => o
    [5] =>  
    [6] => W
    [7] => o
    [8] => r
    [9] => l
    [10] => d
)

This converts the string “Hello World” into an array containing each character.

bannerAds