['font-size' => 'px']]; // $quickcss = ['section' => ['color' => '#a74545', 'font-size' => '32px'], 'p' => ['background-color' => '#458da7', 'width' => '7px']]; $presets = []; $quickcss = []; if (isset($_POST['quickcss'])) { $quickcss = $_POST['quickcss']; } if (isset($_POST['presets'])) { $presets = $_POST['presets']; } if (isset($_POST['active'])) { $active = $_POST['active']; echo '

active

'; var_dump($active); $intersect = array_intersect_key($quickcss, $active); foreach ($intersect as $element => $css) { $intersect[$element] = array_intersect_key($quickcss[$element], $active[$element]); } echo '

intersect

'; var_dump($intersect); $quickcss = $intersect; } if (!empty($_POST['new']['element']) && !empty($_POST['new']['param']) && in_array($_POST['new']['param'], $params)) { $new = array($_POST['new']['element'] => array($_POST['new']['param'] => '')); var_dump($new); $quickcss = array_merge_recursive($quickcss, $new); } echo '

quickcss

'; var_dump($quickcss); echo '

presets

'; var_dump($presets); foreach ($presets as $element => $preset) { foreach ($preset as $param => $unit) { if (array_key_exists($element, $quickcss) && array_key_exists($param, $quickcss[$element])) { $quickcss[$element][$param] .= $unit; } } } $jsonquickcss = json_encode($quickcss); var_dump($jsonquickcss); $string = ''; foreach ($quickcss as $key => $css) { $string .= PHP_EOL . $key . ' {'; foreach ($css as $param => $value) { $string .= PHP_EOL . ' ' . $param . ': ' . $value . ';'; } $string .= PHP_EOL . '}' . PHP_EOL; } var_dump($string); echo '
'; foreach ($quickcss as $element => $css) { echo '

' . $element . '

'; foreach ($css as $param => $value) { echo ''; if (in_array($param, $color)) { echo ''; echo ''; } if (in_array($param, $size)) { echo ''; echo ''; $unit = preg_replace('/\d/', '', $quickcss[$element][$param]); ?> ' . $param . ''; echo ''; $unit = preg_replace('/\d/', '', $quickcss[$element][$param]); ?> Add element'; echo ''; echo ''; echo '
'; echo '
'; ?>

Yolo babyzesssssss

Note that the values of array need to be valid keys, i.e. they need to be either integer or string. A warning will be emitted if a value has the wrong type, and the key/value pair in question will not be included in the result. If a value has several occurrences, the latest key will be used as its value, and all others will be lost.