Table of Contents

Syntax

This method is simply an alias of implode

string join(string $separator, array $parts)

(PHP 4, PHP 5)

$separator A string which is inserted between the individual parts to make a single string.
$parts An array of strings which will be combined.
RETURNS The combined parts from the array as a single string with the $separator between the parts.

What it Does

Join converts an array of strings ($parts) into one single string by placing the $separator text between each of the parts. An array is ordered by its index in the case of a standard array.

If the $parts array has only one element, that element's string will be returned without any $separator. If the $parts array is empty, an empty string will be returned.

Example

// compute the arc tangent for the angle 1.4 radians
$options = array('apple', 'banana', cherry');
$pattern = join('|', $options);
echo 'Fruit Pattern = ' . $pattern;
// outputs:  "apple|banana|cherry"
 
join.txt · Last modified: 2011/02/11 12:30 by orvado
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki