explode function in php

What it it does? 
=> Split a string by string
=> Break a string into an array

Syntax:
explode(separator,string)

Parameter separator : Required. Specifies where to break the string
Parameter string Required. The string to split


Example:

<?php

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

?>



In above example separator is sapce.
String is "piece1 piece2 piece3 piece4 piece5 piece6"

This may helps you.



No comments:

Post a Comment

We are here to listen you, Comment your valueable opinion...!!!