3v4l.org

run code in 300+ PHP versions simultaneously
<?php function AttrFromString($string) { preg_match_all('/(\S+)=["\']?((?:.(?!["\']?\s+(?:\S+)=|[>"\']))+.)["\']?|(\S+)/', $string, $matches); $newlist = array(); for($i = 0; $i < count($matches[0]); $i++) { if (!empty($matches[1][$i])) { array_push($newlist, array($matches[1][$i] , $matches[2][$i])); } else { if(!empty($matches[3][$i])) { array_push($newlist, array($matches[3][$i] , "")); } } } var_dump($newlist); } AttrFromString("test=hallo tes2=\"doei\" test3='lol' no-pe ja test='niks'");
Output for git.master, git.master_jit, rfc.property-hooks
array(6) { [0]=> array(2) { [0]=> string(4) "test" [1]=> string(5) "hallo" } [1]=> array(2) { [0]=> string(4) "tes2" [1]=> string(4) "doei" } [2]=> array(2) { [0]=> string(5) "test3" [1]=> string(3) "lol" } [3]=> array(2) { [0]=> string(5) "no-pe" [1]=> string(0) "" } [4]=> array(2) { [0]=> string(2) "ja" [1]=> string(0) "" } [5]=> array(2) { [0]=> string(4) "test" [1]=> string(4) "niks" } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
54.34 ms | 402 KiB | 8 Q