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 6579881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:57:14+00:00 2026-05-25T15:57:14+00:00

So what I have is an array of things. The items in the array

  • 0

So what I have is an array of things. The items in the array are put into a drop down with the tag, nothing new or complicated about that but here’s the (current working) code anyway:

<?php foreach($roles as $role): ?>
    <option value="<?php echo $role['id']; ?>"><?php echo $role['name']; ?></option>
<?php endforeach ?>

Now what needs to happen, is that if the $role[‘name’] is “Basic”, it should not be displayed. I have been trying (and googling) for this, and I have been unsuccessful. I didn’t think it was that big of a deal.

Here’s what I’m trying:

<?php foreach($roles as $role): ?>
    <?php if(!$role['name'] == "Basic") { ?>
    <option value="<?php echo $role['id']; ?>"><?php echo $role['name']; ?></option>
    <?php } ?>
<?php endforeach ?>

When I try that it doesn’t add any fields to the drop down at all, so I’m obviously missing something here. Any tips would be appreciated, thanks!

  • 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-25T15:57:15+00:00Added an answer on May 25, 2026 at 3:57 pm

    Your problem is with operator precedence [docs]:

    !role['name'] == "Basic"
    

    Assuming that role['name'] is never empty or contains the string "0" (see converting to boolean), this will be evaluated as

    false == "Basic"
    

    which is always false. Use != instead or write !(role['name'] == "Basic").

    You can use the alternative style for the if statement too:

    <?php foreach($roles as $role): ?>
        <?php if($role['name'] != "Basic"): ?>
            ...
        <?php endif ?>
    <?php endforeach ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object that act on UserDefaults. It adds things into an Array
I have a string-array in my strings.xml file that has multiple items in it.
First I'm brand new to JS but have an idea that object classes are
I have array of select tag. <select id='uniqueID' name=status> <option value=1>Present</option> <option value=2>Absent</option> </select>
Let's say I have array of bytes: byte[] arr = new byte[] { 0,
I have an array of numbers that potentially have up to 8 decimal places
I have an array of a few million numbers. double* const data = new
I have asked two previous questions for taking info put into a form and
I have an if statement that checks if an array has a certain item:
I have a String array and I want to show its items in a

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.