//Příklad 3. Splitting a string into matches and their offsets
<?php
$str =
'hypertext language programming';
$chars =
preg_split('/ /',
$str, -1, PREG_SPLIT_OFFSET_CAPTURE
);
print_r($chars);
/*will yield:
Array
(
[0] => Array
(
[0] => hypertext
[1] => 0
)
[1] => Array
(
[0] => language
[1] => 10
)
[2] => Array
(
[0] => programming
[1] => 19
)
)
*/
?>