Q:

How to access a property in array of objects without looping through all of them in php?

Is it possible to access a property inside array of objects that all objects have? 
Lets say i have 
array(
  [0] => {
    [id] = 5,
    [name] = 'Name'
    [everyobjecthasme] = sameforall
  }, 

  [1] = >{
    [id] = 6
    [name] = 'Name2'
    [everyobjecthasme] = sameforall
  }
)

Is it possible to access the property everyobjecthasme (which is universal for all objects) in array of this objects without looping since i need only one object to get this property in php?

A:

Assuming your objects all have the property 'everyobjecthasme' you could do something like this:
$obj1 = new stdClass;
$obj1->everyobjecthasme = 'sameforall';
$obj2 = new stdClass;
$obj2->everyobjecthasme = 'sameforall';
// add objects to array
$array = array(
    0=>$obj1,
    1=>$obj2,
);
// access first object's property
echo $array[0]->everyobjecthasme;

