split

split -- split string into array by regular expression

Description

array split(string pattern, string string, int [limit]);

Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by pattern. If an error occurs, returns false.

To get the first five fields from a line from /etc/passwd:

Example 1. split() example

$passwd_list = split( ":", $passwd_line, 5 );

Note that pattern is case-sensitive.

See also: explode() and implode().