PHP: preg_match_all - anyway to capture offset and use the PREG_SET_ORDER flag? -


i need part out matches in more intuitive manner preg_set_order gives while still getting offset of each match. there anyways accomplish this?

i need capture kind of tag , not want post process capture. lookbehind mess.

this tags , there offset pops out 3-dim array excessive:

preg_match_all('|(?<=<)[\/a-za-z]+|',$file,$matches,preg_offset_capture); 

this yields cleaner result dont know offset tags located:

preg_match_all('|<(\/*)([a-za-z]+)[^>]*>|',$file,$matches,preg_set_order) 

so need combination of two:

preg_match_all('|<(\/*)([a-za-z]+)[^>]*>|',$file,$matches,preg_set_order,preg_offset_capture) 

not sure you're looking for, appears you're trying use preg_set_order while still getting offsets?

if so, pass both flags preg_match_all:

preg_match_all($find, $string, $matches, preg_set_order|preg_offset_capture); var_dump($matches) 

numerical flags such these can combined using bit or operator | (vertical pipe).


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -