Please forgive the question as I'm not exactly sure of the terminology for this..
I am trying to create a grid of colour swatches and am using php foreach loop with associative array. I am trying to work out how I can set a variable for each colour and include this within the array as my code does not currently work
<?php
$yellow = 'background: #FECD06';
$green = 'background: #069A48';
$blue = 'background: #6BC9CB';
?>
<?php foreach ($colourSwatch as $swatch => $colour): ?>
<div class="colour">
<div class="colour_box" style="background: <?php echo $colour[colour]; ?>"></div>
<p><?php echo $colour[caption]; ?></p>
</div>
<?php endforeach ?>
Array
$colourSwatch = array(
colour1 => array(
colour => $yellow,
caption => "RAL 1023"
),
colour2 => array(
colour => $green,
caption => "RAL 2004"
),
colour3 => array(
colour => $blue,
caption => "RAL 3020"
)
)