PHP – Turn Strings into Arrays with explode()

The explode() function allows you to turn a String into an Array based on a separator you define.

explode()

explode.php

<?php

$string = "This is a string, that I will EXPLODE, in this project. Play around with it. See how seperators work.";

$stringArray = explode(".",$string);

echo $string;

echo "<br><br>";

var_dump($stringArray);

echo "<br><br>";

foreach($stringArray as $word) {
    echo $word."<br>";
}

?>

Be the first to comment

Leave a Reply