top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the use of explode() function in PHP ?

0 votes
714 views
What is the use of explode() function in PHP ?
posted Dec 26, 2017 by Jdk

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

3 Answers

0 votes

The explode() function breaks a string into an array.It Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string delimiter.
Example:

$values  = "val1 val2 val3";
$splitValues = explode(" ", $values);
echo $splitValues[0]; // val1
echo $splitValues[1]; // val2
echo $splitValues[3]; // val3
answer Dec 26, 2017 by Madhavi Latha
0 votes

The explode() function breaks a string into an array. It return an array of string, each of which is a substring of string formed by splitting it on boundaries formed by the string delimiter.

EX.

$val = "val1 val2 val3";
$splitVal = explode(" ", &val);
echo $splitVal [0];
echo $splitVal [1];
echo $splitVal [2];
answer Oct 25, 2019 by Siddhi Patel
0 votes

The explode() function breaks a string into an array.

syntax: explode(separator,string,limit)

example :
<?php $str = "Hello world. It's a beautiful day."; print_r (explode(" ",$str)); ?>

answer Nov 4, 2019 by Ifour Parth
...