Hello all, im new to these boards but i hope someone can help me with this one.
Basically i was wondering if anyone could help me write a function that can parse a css stylesheet document and return an array of the stylesheets
so lets say the sheet is like this
/comment field one/
.style1
{
font-family: arial;
color: white;
}
/comment field two/
.style2
{
font-family: verdana;
color: black;
overflow: hidden;
}
so then the function would basically strip out the comments as i dont want them, so id need some way of saying
everything between this point / and this point / is equal to ""
so it gets rid of the comment
then id need to parse by the . i guess and then parse by ; to get each line, then parse by : to split the styles i guess
so the array would be a multidimensional one and you will get an array like this maybe
array( ('.sheet1','{','font-family:','arial;','color:','white;','}'),
('.sheet2','{','font-family:','verdana;','color:','black;','overflow:','hidden;','}'));
then i can use this array then to populate a database field holding the stored styles
so it could be like
UPDATE $array[1] SET $array[3]=$array[4] etc.....
so perhaps it would be better to just ignore things like { } in the array as theyre not needed by the database
anyway it would be great if someone could help me along with this function so basically you give the function a filename
function importCSS($file)
it parses it and returns a multidimensional array that can then be traversed and create UPDATE queries out of it, or maybe even return the queries in an array, i think that would be better, to return all the created queries in an array, then i could just loop through the array calling the mysql_query command.
also my tables are named as the style name
so i have a table called style1 for instance and each field is every style that you can have
so:
font_size | font_family | color etc......
note that the fields are spaced with and not a - like in a stylesheet, so they would need to replace the - with a in the array
anyway thats what i need help with, i hope im not asking for too much. But id sure appreciate the help.
Kind regards
Harvey