public static function parseAttrs($attr)
    {
        /*
         * Skip empty strings
         */
        if (trim($attr) == '') {
            return '';
        }

        /*
         * Match all attribute like parts from string.
         */
        preg_match_all('/[a-zA-Z0-9-_:.]+(\s?=\s?("|\')[^\2]*\2|\s)/U', $attr, $attr);

        /*
         * Get the interessting part.
         */
        $attr = $attr[0];

        $r = array();
        foreach ($attr as $k => $v) {
            /*
             * Skip empty matches
             */
            if (trim($v) == '') {
                continue;
            }

            /*
             * Split by the first = symbol.
             */
            $e = explode('=', $v, 2);
            /*
             * attribute name.
             */
            $at = trim($e[0]);
            /*
             * attribute value.
             */
            $val = isset($e[1]) ? trim($e[1]) : null;

            if ($val !== null) {
                /*
                 * trim the quotation symbols
                 */
                $val = trim($val, substr($val, 0, 1));
            }

            /*
             * store it in the return variable.
             */
            $r[$at] = $val;
        }

        return $r;
    }
public static function parseAttrs($attr)
    {
        /*
         * Skip empty strings
         */
        if (trim($attr) == '') {
            return '';
        }

        /*
         * Match all attribute like parts from string.
         */
        preg_match_all('/[a-zA-Z0-9-_:.]+(\s?=\s?("|\')[^\2]*\2|\s)/U', $attr, $attr);

        /*
         * Get the interessting part.
         */
        $attr = $attr[0];

        $r = array();
        foreach ($attr as $k => $v) {
            /*
             * Skip empty matches
             */
            if (trim($v) == '') {
                continue;
            }

            /*
             * Split by the first = symbol.
             */
            $e = explode('=', $v, 2);
            /*
             * attribute name.
             */
            $at = trim($e[0]);
            /*
             * attribute value.
             */
            $val = isset($e[1]) ? trim($e[1]) : null;

            if ($val !== null) {
                /*
                 * trim the quotation symbols
                 */
                $val = trim($val, substr($val, 0, 1));
            }

            /*
             * store it in the return variable.
             */
            $r[$at] = $val;
        }

        return $r;
    }
public static function parseAttrs ( $ attr ) { /*
         * Skip empty strings
         */ if ( trim ( $ attr ) == '' ) { return '' ; } /*
         * Match all attribute like parts from string.
         */ preg_match_all ( '/[a-zA-Z0-9-_:.]+(\s?=\s?("|\')[^\2]*\2|\s)/U' , $ attr , $ attr ) ; /*
         * Get the interessting part.
         */ $ attr = $ attr [ 0 ] ; $ r = array ( ) ; foreach ( $ attr as $ k => $ v ) { /*
             * Skip empty matches
             */ if ( trim ( $ v ) == '' ) { continue ; } /*
             * Split by the first = symbol.
             */ $ e = explode ( '=' , $ v , 2 ) ; /*
             * attribute name.
             */ $ at = trim ( $ e [ 0 ] ) ; /*
             * attribute value.
             */ $ val = isset ( $ e [ 1 ] ) ? trim ( $ e [ 1 ] ) : null ; if ( $ val !== null ) { /*
                 * trim the quotation symbols
                 */ $ val = trim ( $ val , substr ( $ val , 0 , 1 ) ) ; } /*
             * store it in the return variable.
             */ $ r [ $ at ] = $ val ; } return $ r ; }
Parses tag attributes into an array.

@param string $attr a sting with attributes or a starting tag

@return array  the attributes in array form.
Parses tag attributes into an array .