Jump to content

css file to array help


iwarlord

Recommended Posts

hi everyone. I hope somebody can help me.

 

I'm attempting to convert a css file into an array such as

 

Array

(

[0] => Array ([.classname1] => padding:0px;margin:0px;)

[1] => Array ([.classname1] => color:#000;)

...

)

 

which would simple enough if it weren't for groups which I'm trying to get as

 

Array

(

[0] => Array ([.class1] => font-size:1em;[.class2] => font-size:1em;[.class3] => font-size:1em;)

...

)

 

and child classes I'm trying to get as

 

Array

(

[0] => Array ([.class1] => Array ([.class2] => Array ([.class3] => Array ([.class4] => color:blue;) ) ) )

...

)

 

so basically i want to convert this example string...

 

.class1, class2, class3{font-size:1em;}

.class1 .class4{color:#fff;}

.class1 .class5{color:#ccc;}

#id1, #id2, #id3{font-size:2em;}

 

into this

 

Array

(

[0] => Array

(

[.class1] => Array([.class4]=>color:#fff; [.class5]=>color:#ccc;)

[.class2] => font-size:1em;

[.class3] => font-size:1em;

)

[1] => Array

(

[#id1] => font-size:2em;

[#id2] => font-size:2em;

[#id3] => font-size:2em;

)

)

 

I'm getting in a real muddle doing this. Has anybody done this before please?

Link to comment
https://forums.phpfreaks.com/topic/121736-css-file-to-array-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.