by @codeexamples

Converting string into an array in PHP

Home » php » Converting string into an array in PHP

PHP has a built-in expolde() function by using that we can convert a string into an array.

Here is an example that converts the string Good morning sun to an array.

$str = "Good morning sun";
print_r (explode(" ", $str));

Output:

Array
(
    [0] => Good
    [1] => morning
    [2] => sun
)