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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.