3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $attrPattern = '/([^=]*)=(["\']??)([^"\']*?)\\2/siU'; $attr = 'target="_parent" data-bar="baz"'; preg_match_all($attrPattern, $attr, $matches, PREG_SET_ORDER ^ PREG_OFFSET_CAPTURE); var_dump($matches);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(2) { [0]=> array(4) { [0]=> array(2) { [0]=> string(16) "target="_parent"" [1]=> int(0) } [1]=> array(2) { [0]=> string(6) "target" [1]=> int(0) } [2]=> array(2) { [0]=> string(1) """ [1]=> int(7) } [3]=> array(2) { [0]=> string(7) "_parent" [1]=> int(8) } } [1]=> array(4) { [0]=> array(2) { [0]=> string(15) " data-bar="baz"" [1]=> int(16) } [1]=> array(2) { [0]=> string(9) " data-bar" [1]=> int(16) } [2]=> array(2) { [0]=> string(1) """ [1]=> int(26) } [3]=> array(2) { [0]=> string(3) "baz" [1]=> int(27) } } }