PHP Manualpreg_split(PHP 4, PHP 5) preg_split — Split string by a regular expression Description
array 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 Changelog
Examples
Example #1 preg_split() example : Get the parts of a search string
<?php
Example #2 Splitting a string into component characters
<?php
Example #3 Splitting a string into matches and their offsets
<?php 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(). See Also
![]() |
PHP-Index
New Tutorial entries
|