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

  • Home
  • SEARCH
  • 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 8474279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:35:08+00:00 2026-06-10T17:35:08+00:00

Hope that title made sense but my issue is i have an object with

  • 0

Hope that title made sense but my issue is i have an object with an array like this, this is just 1 from the array as an example

    object(stdClass)#6 (3) {
  ["items"]=>
  array(40) {
    [0]=>
    object(stdClass)#7 (22) {
      ["id"]=>
      int(46)
      ["parentId"]=>
      int(0)
      ["name"]=>
      string(22) "Complete monthly wages"
      ["description"]=>
      string(294) "Complete monthly wages<span style=""></span><br /><div>Complete monthly wages<span style=""></span><br /></div><div>Complete monthly wages<span style=""></span><br /></div><div>Complete monthly wages<span style=""></span><br /></div><div>Complete monthly wages<span style=""></span><br /></div>"
      ["tags"]=>
      string(0) ""
      ["projectId"]=>
      int(12)
      ["ownerId"]=>
      int(1)
      ["groupId"]=>
      int(0)
      ["startDate"]=>
      string(19) "2012-09-03T00:00:00"
      ["priority"]=>
      int(2)
      ["progress"]=>
      float(0)
      ["status"]=>
      int(10)
      ["createdAt"]=>
      string(19) "2012-09-03T07:35:21"
      ["updatedAt"]=>
      string(19) "2012-09-03T07:35:21"
      ["notifyProjectTeam"]=>
      bool(false)
      ["notifyTaskTeam"]=>
      bool(false)
      ["notifyClient"]=>
      bool(false)
      ["hidden"]=>
      bool(false)
      ["flag"]=>
      int(0)
      ["hoursDone"]=>
      float(0)
      ["estimatedTime"]=>
      float(0)
      ["team"]=>
      object(stdClass)#8 (3) {
        ["items"]=>
        array(2) {
          [0]=>
          object(stdClass)#9 (1) {
            ["id"]=>
            int(2)
          }
          [1]=>
          object(stdClass)#10 (1) {
            ["id"]=>
            int(1)
          }
        }
        ["count"]=>
        int(2)
        ["total"]=>
        int(2)
      }
    }

As we can see it has a team section and this is my focus

["team"]=>
          object(stdClass)#8 (3) {
            ["items"]=>
            array(2) {
              [0]=>
              object(stdClass)#9 (1) {
                ["id"]=>
                int(2)
              }
              [1]=>
              object(stdClass)#10 (1) {
                ["id"]=>
                int(1)
              }
            }
            ["count"]=>
            int(2)
            ["total"]=>
            int(2)
          }
        }

As you can see there is 2 id’s in there, 1 and 2, there could be anything up to 30 or so but i cant figure out how to efficently tell it to search the whole array.

If i use this it works as long as the Id 1 happens to be the first item in id but thats obviously not always the case. My aim is to search through the object and just run code IF the users ID is in the team array, im new to php and objects in particular so hope someone can point me in the right direction

foreach($tasksList->items as $task_details) 
{
    if($task_details->team->items->id === 1)
    {
        echo "My Code";

    }


}
  • 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-06-10T17:35:09+00:00Added an answer on June 10, 2026 at 5:35 pm

    Your code (and the [team] section you pasted above) seems to miss the fact that team->items is an array. In the top sample, it looks like:

    ["team"]=>
      object(stdClass)#8 (3) {
        ["items"]=>
        /* It's an array! */
        array(2) {
         ...
        }
      }
    

    It won’t have an id property directly. Instead, you need to iterate over team->items:

    foreach ($taskList->items as $task_details) {
      foreach ($task_details->team->items as $key => $value) {
        echo "Team item #: $key ... Team id: $value->id\n";
        if ($value->id === 1) {
           echo "Matched Team ID 1\n";
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hope that title isn't too cryptic. I have an array with a DATETIME object
I hope the title makes sense. I have a set of items that I
I hope that title makes some sense. I have UIView (created in IB) where
The title is probably not accurate but I hope that reading this post you
I hope that title is clear enough. I have 2 projects, MyProject.Website (ASP.NET MVC3
I hope the title of this question makes sense. What I want to know
the title pretty much explains it. Please note that this is a WebKit-specific issue
I don't think title is making any sense, so I hope that I can
[I hope that this question is not too broad, I think that the subject
Not too sure how to formulate my question and I hope that this is

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.