| preg_splitSplit string by a regular expression Description
   arrayfalse preg_split( string $pattern,string $subject,int $limit= -1,int $flags= 0) Split the given string by a regular expression. Parameters
 
 Return Values
   Returns an array containing substrings of  Errors/Exceptions
If the regex pattern passed does not compile to a valid regex, an  Examples
 Example #1 preg_split example : Get the parts of a search string The above example will output: 
Array
(
    [0] => hypertext
    [1] => language
    [2] => programming
)
 Example #2 Splitting a string into component characters The above example will output: 
Array
(
    [0] => s
    [1] => t
    [2] => r
    [3] => i
    [4] => n
    [5] => g
)
 Example #3 Splitting a string into matches and their offsets The above example will output: 
Array
(
    [0] => Array
        (
            [0] => hypertext
            [1] => 0
        )
    [1] => Array
        (
            [0] => language
            [1] => 10
        )
    [2] => Array
        (
            [0] => programming
            [1] => 19
        )
)
NotesTip
    If you don't need the power of regular expressions, you can choose faster (albeit simpler) alternatives like explode or str_split. Tip
    If matching fails, an array with a single element containing the input string will be returned. |