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 implode() FUNCTION IN PHP

The implode function is the reverse of the explode function and joins the elements of an array into a single string. It takes two arguments, the glue and the array of elements. It returns a single string of the elements of an array with the glue between them.

Example 1:

$myArray=array('My', 'name', 'is', 'John');

$newstring=implode(" ",$myArray);

echo $newstring;

The above will output: My name is John. The glue is the single whitespace.

Example 2:

$myArray=array('apples', 'oranges', 'banana');

$newstring=implode(",",$myArray);

echo $newstring;

The above will output: apples, oranges, banana. The glue is the , character.

Home | Privacy Policy | Terms Of Use | Contact Us