Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9189251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:11:58+00:00 2026-06-17T20:11:58+00:00

I retrieve with PHP a css file in my database. So i have :

  • 0

I retrieve with PHP a css file in my database.

So i have : $mycss = "SOME CSS SOME CSS SOME CSS"

In this $mycss, i can have :

div.coul01,.red,.coul01{
    color:#663333;
}
div.coul02,.blue,.coul02{
    color:#3366CC;
}

For this example, i need to retrive in PHP, for each instruction that begins with div. the second element, here “red” and “blue”.

Do you have any ideas ? Thanks !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:11:59+00:00Added an answer on June 17, 2026 at 8:11 pm

    If you really don’t want to use any library and want to stick to regular expressions, this will work for you:

    <?php
    $mycss = "body,div.coul01,.white,.coul01{
        color:#000000;
    }
    div.coul01,.red,.coul01{
        color:#663333;
    }
    div.coul02,.blue,.coul02{
        color:#3366CC;
    }
    div.coul02,.grey,.coul02{
        color:#C0C0C0;
    }";
    preg_match_all("/^div\.[^,{]*,[\.#](\w+)/ms", $mycss, $matches, PREG_PATTERN_ORDER, 0);
    ?>
    

    and then in your $matches variable you will have something like this:

    $matches[0][0]  div.coul01,.red
    $matches[0][1]  div.coul02,.blue
    $matches[0][2]  div.coul02,.grey
    $matches[1][0]  red
    $matches[1][1]  blue
    $matches[1][2]  grey
    

    $matches[1] is what you are looking for

    Example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so I am using php to retrieve data from mysql database. This data is
PHP lists this example as a way to retrieve database data. <?php $return =
I have this ac.php file and this result.php file I want to use the
I have a PHP script on a server <?php // retrieve POST vars $comment
How can I insert an image in MySQL and then retrieve it using PHP?
I'm storing Points Of Interest (POI) in PostgreSQL database, and retrieve them via PHP
I have two float variables that are equal, I retrieve them by PHP and
Iam trying to retrieve data from mysql database into stylesheet.php but it is not
There is a php file ( current.php ) with some variables, like: function do()
I can't seem to figure out this problem for some reason my piece of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.