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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:07:19+00:00 2026-05-23T20:07:19+00:00

I am currently stumped while searching for an answer, but I have an array

  • 0

I am currently stumped while searching for an answer, but I have an array which contains information relating to a tournament, as seen below.

I would like to search through this Array of arrays for specifically the opponent key, and determine if they are all -2. This is because the logic is that -2 is a bye, so if all people have -2 as their opponent, this means that all brackets have been finished.

My initial thought was just do an array_search(!(-2), $anArray), but that obviously didn’t work and I hit myself on the head for thinking it would be that easy haha. Thanks.

EX:

Array ( 
    [0] => Array ( [dId] => 11 [uId] => 3 [id] => 1 [round] => 0 [opponent] => 3 [bracket] => 0 )
    [1] => Array ( [dId] => 11 [uId] => 5 [id] => 2 [round] => 0 [opponent] => -2 [bracket] => 1 )
    [2] => Array ( [dId] => 11 [uId] => 10 [id] => 3 [round] => 0 [opponent] => 1 [bracket] => 0 ) )
  • 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-23T20:07:21+00:00Added an answer on May 23, 2026 at 8:07 pm

    This function will return true if all opponents are -2 and false if there is a single opponent != -2:

    function all_opponent_search($arr){
        for($i = 0; $i < count($arr); $i++)
            if($arr[$i]['opponent'] != -2)
                return false;
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the answer for this question is probably simple but currently I'm stumped and any
In my app I have a textView which contains real-time messages from my app,
Learning php! I have a sql database which contains a table called 'images' which
Okay, so I have this array. Currently it pulls multiple payment amounts and dates
I currently have most of my page and code working, however, I'm stumped on
I'm currently writing an edit-in-place script for MooTools and I'm a little stumped as
Currently, I don't really have a good method of debugging JavaScript in Internet Explorer and
Currently we have a hybrid ASP/PHP setup connecting to a SQL Server 2005 database.
Currently we have a project with a standard subversion repository layout of: ./trunk ./branches
Currently I'm doing some unit tests which are executed from bash. Unit tests are

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.