PHP explode() function.

Techno PHP

Explode function is used to break a string into an array: You can convert the string into array .
A simple example of explode() function .


Example

<?php
$line="My name is Vishal.";
$line_arr= explode(" ",$line);
print_r($line_arr);
?>
Run

$line -- A variable.

My name is Vishal--String

explode(" ",$line); -- explode() function takes two parameters(arguments) (First parameter is nothing).

Another diffrent example of explode function in which we will pass the two parameters.

Example

<?php 
$line="My name is Vishal";
$line_arr= explode("n",$line);
print_r($line_arr);

?>
Run

explode("n",$line);---

n is a first parameter.

$line second parameter of explode() function .

Type of Arrays.

Index Array .

Two Dimensional Array

Associative Array


Related