// Testing variable to check conditions.
$check = false;
$colors = array('red', 'white', 'green');
$sizes = array('small', 'medium', 'large');
$additionals = array('print', 'no print');
$combinations = array();
foreach($colors as $color) {
foreach($sizes as $size) {
// Add third level depending on the $check variable.
if($check === true) {
foreach($additionals as $additional) {
$combinations[] = $color . '-' . $size . '-' . $additional;
}
} else {
$combinations[] = $color . '-' . $size;
}
}
}
print_r($combinations);