Jump to content

Creating a CSS


cheechm

Recommended Posts

<?php
    /**
    * if reading from a db you have 
    */
$row = array (
             'Name'   => '.page',
             'Width'  => '500px',
             'Height' => '100px'
        );
        
    /**
    * write it to a css file    
    */
$str = $row['Name'] . " {\n" ;
unset ($row['Name']);              // lose "name". The rest are attributes

foreach ($row as $attr => $val)
{
    $str .= "\t$attr: $val;\n";
}
$str .= "}\n\n";

//file_put_contents('my.css', $str);      // uncomment to write to file

echo '<pre>', $str, '</pre>';             // see what would be written
?>

Link to comment
https://forums.phpfreaks.com/topic/96333-creating-a-css/#findComment-493121
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.