All pastes #1584983 Raw Edit

How to use a database to set all

public php v1 · immutable
#1584983 ·published 2009-09-29 21:30 UTC
rendered paste body
// How to use a database to set all CSS values for easy theme creation.// $theme should be the result of a database query, or set manually if you don't have database access.// Result is an array with all of the column names from the database split on the "_" character, and all sections (body, etc) become arrays containing the attributes.// $theme['body']['color'] (or any other value) can then be called in your php.// Modify and use to your liking - SKaReCRoW$theme = array('body_color' => '#FFFF00','body_background-color' => '#77007C','body_font-size' => '11px','table.main_background-color' => '#680080');foreach($theme as $key => $value) { unset($temp); $temp = explode("_", $key); $tempkey = $temp['0']; $tempkey2 = $temp['1']; if (count($temp) == '2') {  $themetemp = array($tempkey2 => $value);  $theme[$tempkey] = array_merge($theme[$tempkey], $themetemp); } else {  $theme[$tempkey] = $value; }}