public static function cssStringToArray($css)
    {
        $statements = explode(';', preg_replace('/\s+/s', ' ', $css));
        $styles = array();
        foreach ($statements as $statement) {
            $statement = trim($statement);
            if ('' === $statement) {
                continue;
            }
            $p = strpos($statement, ':');
            if ($p <= 0) {
                continue;
            } // invalid statement, just ignore it
            $key = trim(substr($statement, 0, $p));
            $value = trim(substr($statement, $p + 1));
            $styles[$key] = $value;
        }
        return $styles;
    }
public static function cssStringToArray($css)
    {
        $statements = explode(';', preg_replace('/\s+/s', ' ', $css));
        $styles = array();
        foreach ($statements as $statement) {
            $statement = trim($statement);
            if ('' === $statement) {
                continue;
            }
            $p = strpos($statement, ':');
            if ($p <= 0) {
                continue;
            } // invalid statement, just ignore it
            $key = trim(substr($statement, 0, $p));
            $value = trim(substr($statement, $p + 1));
            $styles[$key] = $value;
        }
        return $styles;
    }
public static function cssStringToArray ( $ css ) { $ statements = explode ( ';' , preg_replace ( '/\s+/s' , ' ' , $ css ) ) ; $ styles = array ( ) ; foreach ( $ statements as $ statement ) { $ statement = trim ( $ statement ) ; if ( '' === $ statement ) { continue ; } $ p = strpos ( $ statement , ':' ) ; if ( $ p <= 0 ) { continue ; } // invalid statement, just ignore it $ key = trim ( substr ( $ statement , 0 , $ p ) ) ; $ value = trim ( substr ( $ statement , $ p + 1 ) ) ; $ styles [ $ key ] = $ value ; } return $ styles ; }
Convert CSS string to array

@param string $css list of CSS properties separated by ;
@return array name=>value pairs of CSS properties
Convert CSS string to array