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// Example 1
4$pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
5$pieces = explode(" ", $pizza);
6echo $pieces[0]; // piece1
7echo $pieces[1]; // piece2
8
9// Example 2
10$data = "foo:*:1023:1000::/home/foo:/bin/sh";
11list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data);
12echo $user; // foo
13echo $pass; // *
14
15?>
16
17
1$list = "one,two,three";
2$sep_char = ",";
3// array of all needed items: "one", "two", "three"
4$arr = explode($sep_char, $list);
5// array of max two items: "one", "two,three"
6$arr = explode($sep_char, $list, 2);
1<?php
2 // php explode function => converting text into array
3$str = "Hello world. It's a beautiful day.";
4print_r (explode(" ",$str)); // here we define space for breaking we can change space with particular, commna or etc
5// results ['hello','world.','It's','a','beautiful','day.']
6
7?>