PHP function

Explode ( ) Function in PHP

Explode function split a line of text into more then one parts. For example, if you have Student name in one sentence and you want to break these text and split each name and then store in array, then you can use Explode ( ) function.
$names=" Tauqeer, Bilal , Nadeem Ali, Muhammad saleem" ;
if you want to display the result As:
Name
Tauqeer
Bilal
Nadeem Ali
Muhammad Saleem
So for this purpose first we spilt the line of text and then printed each part in next line:


<?PHP
$text=" Tauqeer, Bilal , Nadeem Ali,  Muhammad saleem" ; 
$names= explode( "," , $text );
foreach($names as $x)
echo $x ."<br>";
?>

In above code first we Spilt the text with explode function. and store each name in array $names. In next step foreach loop access the each elemnt of array store in $x and then display the name in separate line.