3v4l.org

run code in 300+ PHP versions simultaneously
<?php function AttrFromString($string) { preg_match_all('/(\S+)=["\']?((?:.(?!["\']?\s+(?:\S+)=|[>"\']))+.)["\']?|(\S+)/', $string, $matches); var_dump($matches); $items = explode(" ", $string); $newlist = array(); foreach($items 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); } } } AttrFromString("test=hallo tes2=\"doei\" test3='lol' nope ja");

preferences:
33.22 ms | 402 KiB | 5 Q