#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    2
    Rep Power
    0

    CSS Body Background color with php


    My problem is that I need to get the Body Background color that is in a css file using php to then introduce this color to an applet.
    My CSS file has:

    BODY {
    FONT-SIZE: 12px;
    COLOR: #6699ff;
    BACKGROUND-COLOR: #ffffff;
    SCROLLBAR-FACE-COLOR: #FFFFFF;
    SCROLLBAR-HIGHLIGHT-COLOR: #CC6699;
    SCROLLBAR-SHADOW-COLOR: #CC6699;
    SCROLLBAR-3DLIGHT-COLOR: #CC6699;
    SCROLLBAR-ARROW-COLOR: #CC6699;
    SCROLLBAR-TRACK-COLOR: #FFFFFFF;
    SCROLLBAR-DARKSHADOW-COLOR: #CC6699;

    FONT-FAMILY: "Times", serif;

    }

    But I use different CSS so very time I change the file I need to know in the php page what BACKGROUND-COLOR it has.
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2004
    Location
    Central Washington (USA)
    Posts
    518
    Rep Power
    11
    this is part of your solution.. a match once you've got the file read. You'll have to read the css file:
    PHP Code:
    $txt 'BODY {
    FONT-SIZE: 12px;
    COLOR: #6699ff;
    BACKGROUND-COLOR: #ffffff;
    SCROLLBAR-FACE-COLOR: #FFFFFF;
    SCROLLBAR-HIGHLIGHT-COLOR: #CC6699;
    SCROLLBAR-SHADOW-COLOR: #CC6699;
    SCROLLBAR-3DLIGHT-COLOR: #CC6699;
    SCROLLBAR-ARROW-COLOR: #CC6699;
    SCROLLBAR-TRACK-COLOR: #FFFFFFF;
    SCROLLBAR-DARKSHADOW-COLOR: #CC6699;
    FONT-FAMILY: "Times", serif;
    }'
    ;
    preg_match("/body\s*\{.*background\-color\s*:(.*);/iUs"$txt$matches);
    echo 
    $matches[1]; 
    Last edited by twostepted; May 18th, 2004 at 12:12 AM.
  4. #3
  5. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2004
    Location
    Central Washington (USA)
    Posts
    518
    Rep Power
    11
    Sorry. I had to go before. Here is the rest.. assuming that you have the correct permissions on the server. If you don't you'll have to use something else to open the file... maybe ftp functions will work for you.
    PHP Code:
    $arrLines file('style.css');
    $txt implode(''$arrLines); 

IMN logo majestic logo threadwatch logo seochat tools logo