1<?php
2// It doesnt get any better than this Example
3$pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
4$pieces = explode(" ", $pizza);
5echo $pieces[0]; // piece1
6echo $pieces[1]; // piece2
1 $str = "Hello, kinjal, how, are, you";
2
3 // it will convert string to array
4 $s1 = explode(",", $str);
5 echo "<pre>";
6 print_r($s1);
1
2<?php
3$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
4
5$key = array_search('green', $array); // $key = 2;
6$key = array_search('red', $array); // $key = 1;
7?>
8
9
1<html>
2<body bgcolor="pink">
3<h3>Implode Function</h3>
4<?php
5$arr=array ('I','am','simple','boy!');
6echo implode(" ",$arr);
7$str="I am simple boy!";
8print_r(explode(" ",$str));
9?>
10</body>
11</html>
1<?php
2$str = "Hello world. It's a beautiful day.";
3$split = explode(" ",$str);
4$hello = $split[0];
5$world = $split[1];
6?>