-3
stdClass Object
([abc] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 10

                )

            [1] => stdClass Object
                (
                    [id] => 11

                )

            )

)

I have declared one PHP array. Now I want to get value of id in php variable. How I can get using foreach loop.

Miggy
  • 816
  • 7
  • 16
Anil
  • 63
  • 1
  • 8

2 Answers2

0

Use

foreach($object->abc as $item)
{
    echo ($item->id);
}
Ali Kaviani
  • 321
  • 2
  • 6
0

You can do it like this:

$id=$abc[0]->id;
dferenc
  • 7,918
  • 12
  • 41
  • 49
Mosin
  • 600
  • 6
  • 18