Explode() | Two Args (explode-on, string)

Before

Buick,Ford,Chevy,Pontiac,Nissan,Honda

After explode()

array(6) { [0]=> string(5) "Buick" [1]=> string(4) "Ford" [2]=> string(5) "Chevy" [3]=> string(7) "Pontiac" [4]=> string(6) "Nissan" [5]=> string(5) "Honda" }

One More Example

Before

Frank Greg Jerome Gina Al Henry Stephanie Inga Chris

After explode()

array(9) { [0]=> string(5) "Frank" [1]=> string(4) "Greg" [2]=> string(6) "Jerome" [3]=> string(4) "Gina" [4]=> string(2) "Al" [5]=> string(5) "Henry" [6]=> string(9) "Stephanie" [7]=> string(4) "Inga" [8]=> string(5) "Chris" }


The code used for index.php is below:


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../styles.css">
    <title>PHP: Explode</title>
</head>
<body>
    
<h1 class="lesson-h1" >Explode() | Two Args (explode-on, string)</h1>
    
<?php
    $string = "Buick,Ford,Chevy,Pontiac,Nissan,Honda";
    echo "<h3 style='margin: 0;'>Before</h3>";
    echo "<p>$string</p>";

    echo "<h3 style='margin: 0;'>After explode()</h3>";
    echo "<p>".var_dump(explode(',', $string))."</p>";
?>

<h2>One More Example</h2>

<?php
    $customers = "Frank Greg Jerome Gina Al Henry Stephanie Inga Chris";
    echo "<h3 style='margin: 0;'>Before</h3>";
    echo "<p>$customers</p>";

    echo "<h3 style='margin: 0;'>After explode()</h3>";
    echo "<p>".var_dump(explode(' ', $customers))."</p>";

    include('../show_code.php');
    show_code('index.php');

?>

</body>
</html>