3v4l.org

run code in 300+ PHP versions simultaneously
<?php function AttrFromString($string) { preg_match_all('/(\S+)=["\']?((?:.(?!["\']?\s+(?:\S+)=|[>"\']))+.)["\']?|(\S+)/', $string, $matches); $newlist = array(); foreach($matches as $yes) { if (strpos($yes, "=")!==false) { $as = explode('=', $yes); } else { $as[0] = $yes; $as[1] = ""; } if (substr($as[1], 0,1) == "'" || substr($as[1], 0,1) == '"') { $as[1] = substr($as[1],1,strlen($as[1])-2); } array_push($newlist, array($as[0]. $as[1])); } 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
Fatal error: Uncaught TypeError: strpos(): Argument #1 ($haystack) must be of type string, array given in /in/SraVK:6 Stack trace: #0 /in/SraVK(6): strpos(Array, '=') #1 /in/SraVK(20): AttrFromString('test=hallo tes2...') #2 {main} thrown in /in/SraVK on line 6
Process exited with code 255.

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:
55.73 ms | 401 KiB | 8 Q