Harry: Parser für css-Dateien

Beitrag lesen

Ups ...

da hab ich doch glatt eine Zeile und ein paar Klammern vergessen :-(
 (tja ... erst Korrekturlesen und dann schicken, net andersrum)

$ar = file($url);
$ps = "";
$selektoren = "";
$as = "";
for($i=0; $<count($ar); $i++)
{ $ps .= $ar[$i];
  if(strstr($ps, "{") && strstr($ps, "}") && substr_count($ps, "{")==substr_count($ps, "}")

// Hier gehört natürlich ganz hinten auch noch eine Klammer hin:
     if(strstr($ps, "{") && strstr($ps, "}") && substr_count($ps, "{")==substr_count($ps, "}"))

{ $ar2 = explode("}", $ps);
    for($j=0; $j<count($ar2); $j++)
    { if(strstr($ar2[$j], "{")

// muß heißen:
         if(strstr($ar2[$j], "{"))

{ $ar3 = explode("{", $ar2[$j]);
        $selektoren[$as] = trim($ar3[0]);
        $ar3++;
      }
    }

// Hier fehlt
     $ps = "";

}
}

Das Ergebnis steht übrigens im Array $selektoren.

Harry