Hi Martin, Am Mo, 2003-12-15 um 10.51 schrieb Martin Samesch: > Hi, > > could somebody please check the following paragraph in > reference/pcre/constants.xml > > rows 59-63: > > If this flag is set, for every occuring match the appendant string > offset will also be returned. Note that this changes the return > value in an array where very element is an array consisting of the > matched string at offset 0 and it's string offset into subject at > offset 1. ... > > There are at least three typos (value_s_, _e_very, its instead of > it's) and maybe "... string offset into subject ..." isn't correct, > too (?).
Jup, that seem to be typos. For a better understanding of the paragraph and a good translation, you may look at following example: <?php $s = 'PHP is doing PCRE'; $splitted = preg_split('/ /', $s, -1, PREG_SPLIT_OFFSET_CAPTURE); print_r ($splitted); ?> What you get is: Array ( [0] => Array ( [0] => PHP [1] => 0 ) [1] => Array ( [0] => is [1] => 4 ) [2] => Array ( [0] => doing [1] => 7 ) [3] => Array ( [0] => PCRE [1] => 13 ) ) If you look at the output you should be able to see what PREG_SPLIT_OFFSET_CAPTURE does. Preg_split basically uses the pattern to split the subject up (as it regulary does). But with that option set you do not get one array with each offset carrying the matched values, but you get as many arrays as you have matches. In the example each array gives you the matched pieces (it's values) in offset 0 and at offset 1 you get the offset of this particiular string-match refering to the beginning ( $s{0} ) of the subject string. Maybe i'm confusing you more than you were before, but i gave a try :) -ali > > Don't know how to correct and translate this last piece. > > Martin