src/Parsing/TagParser.php
public function extractTagAttributes($code)
    {
        $param = array();
        $regexes = array(
            '([a-zA-Z0-9_]+)=([^"\'\s>]+)',  // read the parameters : name=value
            '([a-zA-Z0-9_]+)=["]([^"]*)["]', // read the parameters : name="value"
            "([a-zA-Z0-9_]+)=[']([^']*)[']"  // read the parameters : name='value'
        );

        foreach ($regexes as $regex) {
            preg_match_all('/'.$regex.'/is', $code, $match);
            $amountMatch = count($match[0]);
            for ($k = 0; $k < $amountMatch; $k++) {
                $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
            }
        }

        return $param;
    }
public function extractTagAttributes($code)
    {
        $param = array();
        $regexes = array(
            '([a-zA-Z0-9_]+)=([^"\'\s>]+)',  // read the parameters : name=value
            '([a-zA-Z0-9_]+)=["]([^"]*)["]', // read the parameters : name="value"
            "([a-zA-Z0-9_]+)=[']([^']*)[']"  // read the parameters : name='value'
        );

        foreach ($regexes as $regex) {
            preg_match_all('/'.$regex.'/is', $code, $match);
            $amountMatch = count($match[0]);
            for ($k = 0; $k < $amountMatch; $k++) {
                $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
            }
        }

        return $param;
    }
public function extractTagAttributes ( $ code ) { $ param = array ( ) ; $ regexes = array ( '([a-zA-Z0-9_]+)=([^"\'\s>]+)' , // read the parameters : name=value '([a-zA-Z0-9_]+)=["]([^"]*)["]' , // read the parameters : name="value" "([a-zA-Z0-9_]+)=[']([^']*)[']" // read the parameters : name='value' ) ; foreach ( $ regexes as $ regex ) { preg_match_all ( '/' . $ regex . '/is' , $ code , $ match ) ; $ amountMatch = count ( $ match [ 0 ] ) ; for ( $ k = 0 ; $ k < $ amountMatch ; $ k ++ ) { $ param [ trim ( strtolower ( $ match [ 1 ] [ $ k ] ) ) ] = trim ( $ match [ 2 ] [ $ k ] ) ; } } return $ param ; }
Extract the list of attribute => value inside an HTML tag

@param string $code The full HTML tag to parse

@return array
Extract the list of attribute = > value inside an HTML tag