<?php
function AttrFromString($string) {
preg_match_all('/(\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'");
preferences:
44.66 ms | 402 KiB | 5 Q