Table of Contents

Syntax

array explode(string $delim, string $str [, int $limit])

(PHP 4, PHP 5)

$delim Delimiter used to separte the source string.
$str The source string which will be split appart into an array.
$limit The maximum number of parts (or elements) in the array.
RETURNS The array generated by splitting the source string.

What it Does

Explode takes the source string ($str) and breaks it into smaller parts using the delimiter ($delim) string as a splitting point. Usually, this is used to break a comma-separated list into its individual parts.

A reverse process can be done using the implode function.

Example

// split the month abbreviations
$mon = explode(',', 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec');
 
// split the day-of-the-week
$wday = explode(',' 'M,T,W,Th,F,S,Sn');
 
explode.txt · Last modified: Apr 18, 2008 - 2:00pm (external edit)
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki