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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:55:17+00:00 2026-05-27T12:55:17+00:00

I am finding the value either exists in object array in php. I would’t

  • 0

I am finding the value either exists in object array in php.

I would’t like to traverse whole the object array, Is their any alternative in php for object just like is_array()?

Edited:
if I var_dump($te_ws) then it shows this output . . .

array(2) { [0]=> object(stdClass)#22 (3) { ["id"]=> string(2) "12" ["fk_webapp_id"]=>     string(1) "3" ["fk_tenant_id"]=> string(2) "12" } [1]=>     object(stdClass)#25 (3) { ["id"]=> string(2) "13" ["fk_webapp_id"]=> string(1) "5"     ["fk_tenant_id"]=> string(2) "12" } }


$is_checked = FALSE;
if (!empty($te_ws)) {
 foreach ($te_ws as t) {
  if ($t->id === 4) {
    $is_checked = TRUE;
  }
 }

}

Is it possible to check the value 4 from array of object either exists using php built in function?

  • 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-27T12:55:18+00:00Added an answer on May 27, 2026 at 12:55 pm

    What you are asking for seems very strange. What are you doing that you need to test for membership of a value in an object?

    In simple cases you can just cast an object to an array:

    $object = new stdClass();
    $object->a = 1;
    in_array(1, (array) $object); // True
    

    However this breaks down for any non-trivial object:

    class MyClass {
        public $var1 = 1;
        private $var2 = 2;
        protected $var3 = 3;
    }
    
    $mc = new MyClass();
    
    var_dump((array) $mc); // all properties, even private ones, are included
    in_array(2, (array) $mc); // TRUE, even though you can't GET this value!
    $mc->var2;  // PHP DIES with FATAL ERROR!!!!
    

    The following function will get a little closer to what you describe. But it won’t find properties computed with Magic Methods.

    function in_object($needle, $haystack, $strict=False) {
        if (!is_object($haystack)) {
            throw new InvalidArgumentException("\$haystack is not an object");
        }
        $reflector = new ReflectionObject($haystack);
        $publicproperties = $reflector->getProperties(ReflectionProperty::IS_PUBLIC);
        foreach ($publicproperties as $property) {
            $value = $property->getValue($haystack);
            if (($strict) ? $value===$needle : $value==$needle) {
                return True;
            }
        }
        return False;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any straightforward way of finding a key by knowing the value within
Finding windows FastCGI help is proving very difficult. Any help would be greatly apprciated.
I'm wondering if this is a sufficient algorithm for finding the best value with
I'm finding it impossible to search for a particular value within the Address Bar.
Finding articles with ANY of a set of tags is a relatively simple join,
I'm finding it difficult to find any discussion on best practices for dealing with
I have multiple binary trees stored as an array. In each slot is either
I'm finding it strange that I can't find any information about how to populate
I have a String that's formatted like this: key1=value1;key2=value2;key3=value3 for any number of key/value
The example for finding the value of an input box in jQuery is below.

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.