codingtcher.com
Theme Night
Home
Login

Php explode string to array

//explode example in php
$str = "Hello, kinjal, how, are, you";
// it will convert string to array
$s1 = explode(",", $str);
echo "<pre>";
print_r($s1);

//php explode
$colors  = "red,blue,green,orange";
$colorsArray = explode(",", $colors);

//php explode
$pizza  = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode(" ", $pizza);
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2

Related Code