I have an unsorted and dynamically changing array in php where I have values stored as in "blue", "red", "green". The rest of the array consists of strings like "wet", "dry", "humid". Now I want to print respective titles before printing the strings to my html page. How can I achieve this?
Above code produces problems since if else fires, before all three colors have been echoed out, it will print the heading again.
Edit:
Array: blue, humid, green, wet, dry, red.
echo "<h3>Color</h3><br>";
foreach($array as $value){
if ($value == "blue" || $value == "red" || $value == "green") {
echo $value;
}
echo "<h3>Weather</h3><br>";
foreach($array as $value){
if ($value != "blue" || $value != "red" || $value != "green") {
echo $value;
}
respective titles?