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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:31:26+00:00 2026-06-10T15:31:26+00:00

Im new to objects and im still trying to get my head around it.

  • 0

Im new to objects and im still trying to get my head around it.

Here is the situation i have:

I have info coming from an API formatted as an object with a bunch of variables like this:

public 'id' => int 64
public 'taskId' => int 6
public 'projectId' => int 2
public 'type' => string 'progress' (length=8)
public 'text' => string 'bug5279 main branch fix confirmed beta still an issue with bounties' (length=111)
public 'ownerId' => int 3
public 'progress' => int 0
public 'hoursDone' => float 0.25
public 'createdAt' => string '2012-08-28T09:33:51' (length=19)
public 'notifyProjectTeam' => boolean false
public 'notifyTaskTeam' => boolean false
public 'notifyClient' => boolean false
public 'date' => string '2012-08-28T09:33:51' (length=19)

This is the code i use to produce the above and it returns a bunch of objects
activity List

$activityList = $activityClient->getList( $filter, $offset, $count );

This is the users list

$usersList = $usersClient->getAll();

Now what i want to do is only display the username IF the user hoursDone value is >0

I googled and i can find how to loop through an object but cant seem to find the right keywords to show where conditions and since im new to objects im a bit lost. Here is my code for a simple loop through

// get the usernames 
foreach($usersList->items as $user_details) {
$users[$user_details->id]=$user_details->firstName.' '.$user_details->lastName;
}

// get projects
foreach($tasksList->items  as $task_details) 
{
$tasks[$task_details->id]=$task_details->name;
}

And here is how i loop through the activities

foreach($activityList->items as $workdetails) 
    {
echo "<br><h2>$username</h2><br>";
}
foreach($tasks as $taskid=>$taskname)
    {
    if($userid==$workdetails->ownerId && $taskid==$workdetails->taskId)
        {
         echo "<br>$workdetails->hoursDone<br>";
         echo "<br>$workdetails->text<br>";
        }
    }

Now the problem is i end up with something like this:

John
1
worked on emails

James

Jerry

Pat

Harry
2.50
worked on emails

Mary

Sarah

But i don’t want people to show up unless they have > 0 for hoursDone.

this is the point im really lost on, i dont know where to start to be honest. Any links to answers or examples would be great. This is a mixture of inherited code and my own 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-10T15:31:28+00:00Added an answer on June 10, 2026 at 3:31 pm

    You’re almost there, just do

       foreach($tasks as $taskid=>$taskname){
           if($userid==$workdetails->ownerId && $taskid==$workdetails->taskId && $workdetails->hoursDone > 0){
               echo "<br>$workdetails->hoursDone<br>";
               echo "<br>$workdetails->text<br>";
           }
       }
    

    I added a check to see if the hoursDone value is > 0

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

Sidebar

Related Questions

I'm still trying to get my head around using Java's generics. I have no
new to WPF and MVVM, and trying to get my head around the normal
I'm still trying to get my head around the best way to structure event
I'm still trying to get my head around mocking. Right now, I'm trying to
I am trying to get hibernate to write new objects each time I do
Probably a stupid question but I'm still trying to wrap my head around nHibernate.
I'm trying to get my head around Domain Driven Design and the examples I've
I'm still trying to get to grips with dependency injection and loosely coupled objects.
I am trying to create new Event objects to be persisted in the database
I am trying to integrate the new Open Graph objects , actions and aggregations

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.