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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:09:04+00:00 2026-06-13T00:09:04+00:00

Hello!! i think its very simple question for those who familier with std objects

  • 0

Hello!!

i think its very simple question for those who familier with std objects and arrays in PHP.

Here is my STD Object array:

Array ( [0] => stdClass Object ( [name] => name1 [description] => [category_id] => 17 [category_publish] => 1 [ordering] => 1 [category_parent_id] => 10 ) [1] => stdClass Object ( [name] => name2 [description] => [category_id] => 8 [category_publish] => 1 [ordering] => 1 [category_parent_id] => 0 ) [2] => stdClass Object ( [name] => name3 [description] =>desc [category_id] => 10 [category_publish] => 1 [ordering] => 2 [category_parent_id] => 0 ) [3] => stdClass Object ( [name] => name3 [description] => [category_id] => 16 [category_publish] => 1 [ordering] => 2 [category_parent_id] => 10 ) )

now, i have different array with numbers for example:

$arr=array(17,10);

and i need to check if one of this numbers is equal the [category_id] value (inside the std object), if it is equal, check the next [category_id], and if it’s not, remove all values of this object .
(of course, Other method is to build a new STD Object only with the numbers in the array)

So the result should be:

Array ( [0] => stdClass Object ( [name] => name1 [description] => [category_id] => 17 [category_publish] => 1 [ordering] => 1 [category_parent_id] => 10 ) [2] => stdClass Object ( [name] => name3 [description] =>desc [category_id] => 10 [category_publish] => 1 [ordering] => 2 [category_parent_id] => 0 ) )

Only the array’s with categiry_id =17 and 10 are inside this stdObject..

Thank you very much for your help!!

Eran.

  • 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-13T00:09:05+00:00Added an answer on June 13, 2026 at 12:09 am

    Try this

    $arr=array(17,10);
    foreach ($array as $key => $obj) {
      if (!in_array($obj->category_id, $arr)) {
        unset($array[$key]);
      }
    } 
    // edited, missing closing bracket
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello i have a very simple question, I have initialized some variables and started
I have finally created a very simple Hello World style PHP Extension dll on
Hello guys. I think it isn't possible just using PHP, but just to be
My question is a very simple one i'm sure. It's just I'm not quite
I'm trying to create a very simple contentEditable div input. However, any way that
I have a very simple function in C++: double testSpeed() { using namespace boost;
Firstly apologies if this a very basic question, I'm just curious to know the
Hello and thank for looking at my question. I'm in need to grab some
I generated a very simple runnable jar file using Eclipse's Export-->Java-->Runnable Jar File function.
i have here the code.. <div> <input type=hidden value=hello /> </div> <div> <input type=hidden

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.