public static function cssToArray($css){
        if(!$css) {
            return array();
        }
        $css = str_replace(' /* Do not edit */', '', $css);
        $oldCssArr = explode("\n", $css);
        $newCssArr = array();
        foreach($oldCssArr as $line) {
            if(false === strpos($line, '{')) {
                continue;
            }

            preg_match('~(?P<selector>[^{]+)(\{)(?P<rules>[^}]+)\}~', $line, $matches);

            foreach($matches as $key => &$match){
                if(is_numeric($key)) {
                    continue;
                }
                $match = trim($match);
                if($key === 'rules') {
                    $ruleSet = array_filter(array_map('trim', explode(';', $match)));
                    $match = array();
                    foreach($ruleSet as $rule) {
                        $rule = array_map('trim', explode(':', $rule));
                        $match[$rule[0]] = $rule[1];
                    }
                }
            }

            $newCssArr[$matches['selector']] = $matches['rules'];
        }
        return $newCssArr;
    }
public static function cssToArray($css){
        if(!$css) {
            return array();
        }
        $css = str_replace(' /* Do not edit */', '', $css);
        $oldCssArr = explode("\n", $css);
        $newCssArr = array();
        foreach($oldCssArr as $line) {
            if(false === strpos($line, '{')) {
                continue;
            }

            preg_match('~(?P<selector>[^{]+)(\{)(?P<rules>[^}]+)\}~', $line, $matches);

            foreach($matches as $key => &$match){
                if(is_numeric($key)) {
                    continue;
                }
                $match = trim($match);
                if($key === 'rules') {
                    $ruleSet = array_filter(array_map('trim', explode(';', $match)));
                    $match = array();
                    foreach($ruleSet as $rule) {
                        $rule = array_map('trim', explode(':', $rule));
                        $match[$rule[0]] = $rule[1];
                    }
                }
            }

            $newCssArr[$matches['selector']] = $matches['rules'];
        }
        return $newCssArr;
    }
public static function cssToArray ( $ css ) { if ( ! $ css ) { return array ( ) ; } $ css = str_replace ( ' /* Do not edit */' , '' , $ css ) ; $ oldCssArr = explode ( "\n" , $ css ) ; $ newCssArr = array ( ) ; foreach ( $ oldCssArr as $ line ) { if ( false === strpos ( $ line , '{' ) ) { continue ; } preg_match ( '~(?P<selector>[^{]+)(\{)(?P<rules>[^}]+)\}~' , $ line , $ matches ) ; foreach ( $ matches as $ key => & $ match ) { if ( is_numeric ( $ key ) ) { continue ; } $ match = trim ( $ match ) ; if ( $ key === 'rules' ) { $ ruleSet = array_filter ( array_map ( 'trim' , explode ( ';' , $ match ) ) ) ; $ match = array ( ) ; foreach ( $ ruleSet as $ rule ) { $ rule = array_map ( 'trim' , explode ( ':' , $ rule ) ) ; $ match [ $ rule [ 0 ] ] = $ rule [ 1 ] ; } } } $ newCssArr [ $ matches [ 'selector' ] ] = $ matches [ 'rules' ] ; } return $ newCssArr ; }
Convert incoming CSS to CSS array
This CSS must have the format generated by the online editor

@param $css
@return mixed
Convert incoming CSS to CSS array This CSS must have the format generated by the online editor