Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6763479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:28:51+00:00 2026-05-26T14:28:51+00:00

Ok this is sort of hard to explain but basically i wrote a PHP

  • 0

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>";
        }

    }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:28:51+00:00Added an answer on May 26, 2026 at 2:28 pm

    Maybe this code can help you (if I understand question):

    <?php
    $topClass = true;
    
    $elements = array("hardware", "software", "payment", "service", "optional");
    foreach ($elements as $index => $element) {
        if (floor(count($elements) / 2) == $index) {
            echo "<a class=\"{$element} hw_center lf\"></a>";
            $topClass = false;
        } else { 
            if ($topClass) {
                echo "<a class=\"{$element} hw_top lf\"></a>";
            } else {
                echo "<a class=\"{$element} hw_bottom lf\"></a>";
            }
    
        }
    } 
    

    EDIT: Update after your explain what you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(I know this is a sort of lazy question, but it's oddly hard to
This is kind of hard to explain, so bear with me. In PHP, if
I am having a hard time with this problem which requires a sort of
Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound
I know this sort of code is not best practice, but nevertheless in certain
NOTE : It's sort of hard to google for this, because GET is bringing
I'm having a hard time describing a Flash program that uses a sort of
Ok, this might be a little hard to explain. I'm looking for a way
It's quite hard for me to figure out if this sort of thing has
I guess it's not so hard to do this by hand, but I was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.