PHP

 Home  Computers & Internet  Web Programming PHP
What is PHP?
Echo
Comments
Variables
Constants
Data Types
number_format()
Character Strings
Mathematical Operators
Comparison Operators
Logical Operators
Joining Strings
explode()
implode()
strtolower()
strtoupper()
strlen()
ucfirst()
ucwords()
strrev()
str_replace()
str_repeat()
trim()
strip_tags()
addslashes()
stripslashes()
strpos()
strrpos()
nl2br()
isset()
unset()
empty()
POST
GET
If Statements
If Else Statements
Elseif Statements
Switch Statements
For Loops
While Loops
Do While Loops
Foreach Loops
File Create
File Open
File Read
File Write
File Delete
fgets()
file_get_contents()
Date & Time
$_SERVER
Sessions
Cookies
Arrays

HOW TO USE THE explode() FUNCTION IN PHP

The explode function explodes a string into substrings. It takes two arguments, the separator and the string to be exploded. It returns an array of substrings between the separators.

Example 1:

$fullstring="My-name-is-John";
$newstring=explode("-",$fullstring);

This results in an array of 4 elements, each part a substring and each part separated by the separator (-).

$newstring[0] holds value of: My
$newstring[1] holds value of: name
$newstring[2] holds value of: is
$newstring[3] holds value of: John

Example 2:

$fullstring="Her name is Mary Jenkins";
$newstring=explode(" ",$fullstring);

This results in an array of 5 elements, each part a substring and each part separated by a single whitespace.

$newstring[0] holds value of: Her
$newstring[1] holds value of: name
$newstring[2] holds value of: is
$newstring[3] holds value of: Mary
$newstring[4] holds value of: Jenkins

Home | Privacy Policy | Terms Of Use | Contact Us