I would do array, sample code.. prolly not working 😛 altho if you find a way to do this with math (such as white is 000 and grey could be say 555, maybe the final outcome would then be 222, see second example)
$parents = array($mom,$dad); //Where $mom and $dad are defined as their supplied colors.
if( in_array('grey',$parents) && in_array('white',$parents) ) {
echo 'Child might be light grey';
} elseif( in_array('black',$parents) && in_array('grey',$parents) ) {
echo 'Child might be dark grey';
} elseif ///.... etc
Or my math solution would be:
<?php
function getColor($text) {
$text = strtolower($text);
switch($text) {
case 'white':
return array(15,15,15);
case 'grey':
case 'gray':
return array(8,8,8);
case 'black':
return array(0,0,0);
default:
return FALSE;
}
}
function buildColor(Array $colors) {
$letters = array('A','B','C','D','E','F');
foreach( $colors as $k => $v ) {
if( $v > 9 ) {
$v -= 10;
$colors[$k] = $letters[$v];
}
}
return '#'.implode($colors);
}
$mom = getColor('white');
$dad = getColor('gray');
list($mr,$mg,$mb) = $mom;
list($dr,$dg,$db) = $dad;
$kid = array();
$kid[] = round(($mr+$dr)/2);
$kid[] = round(($mg+$dg)/2);
$kid[] = round(($mb+$db)/2);
echo '<span style="color:'.buildColor($mom).';">Mom</span>'
.' plus '
.'<span style="color:'.buildColor($dad).';">Dad</span>'
.' equals '
.'<span style="color:'.buildColor($kid).';">KID</span>';