I want to combine values from an array to be output into another array as a single flattened value rather than another array. My problem is the final output is always another array, while what I need is to append the other value into the first value using a dash (-), and so on depending on its presence:
If all is present, should output a-b-c, if two of either combination = a-b, a-c, b-c, otherwise simply a or b or c
$classes = array('a', 'b', 'c');
foreach ($classes as $class) {
if (!empty($block[$class])) {
// If all is present, should output a-b-c, if two = a-b, a-c, b-c, otherwise simply a or b or c
$variables['classes_array'][] = ....;
}
}
I think this would do what you want: