Ok this is sort of hard to explain but basically i wrote a PHP function that prints the a tags but needs some logic. Here is what i have so far
function print_a($element_name, $completed_system, $category_name){
// hw_bottom
// hw_top
// hw_center
$elements = array("hardware", "software", "payment", "service", "optional");
$last_category = last_category($completed_system);
if($last_category == $category_name){
echo "<a class=\"{$element_name} hw_center lf\"></a>";
}else{
echo "<a class=\"{$element_name} hw_bottom lf\"></a>";
}
}
and here is how i call it
print_a("hw-tab", $completed_system, 'hardware');
print_a("sw-tab", $completed_system, 'software');
print_a("pp-tab", $completed_system, 'payment');
print_a("serv-tab", $completed_system, 'service');
print_a("ou-tab", $completed_system, 'optional');
all seems ok but my logic is a bit off …basically what i need is that i print either one of the three classes hw_bottom, hw_center, or hw_top and the way my logic is working out now is that if the if condition is met i print hw_center …thats correct …what i need though is that if the if condition matches on anything after the hardware i need to turn all the previous to hw_top so for example:
if the if condition matched on payment then this is what i need
<a class="hw-tab hw_top lf"></a>
<a class="sw-tab hw_top lf"></a>
<a class="pp-tab hw_center lf"></a>
<a class="serv-tab hw_bottom lf"></a>
<a class="ou-tab hw_bottom lf"></a>
As you can see all the ones after payment are hw_bottom and all the ones before are hw_top and it is hw_center….i know this is hard to explain…if anyone needs more info let ms know
UPDATE
HERE is the solution i came up with after reviewing all the answers
function print_a($completed_system){
$topClass = true;
$elements = array("hw-tab" => "hardware", "sw-tab" => "software", "pp-tab" => "payment", "serv-tab" => "service", "ou-tab" => "optional");
$last_category = last_category($completed_system);
foreach ($elements as $key => $element) {
if($last_category == $element){
echo "<a class=\"{$key} hw_center lf\"></a>";
$topClass = false;
} else {
if ($topClass) {
echo "<a class=\"{$key} hw_top lf\"></a>";
} else {
echo "<a class=\"{$key} hw_bottom lf\"></a>";
}
}
}
}
Maybe this code can help you (if I understand question):
EDIT: Update after your explain what you need.