-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
  • 806
  • 6
  • 16
Anil
  • 63
  • 1
  • 8

2 Answers2

0

Use

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

You can do it like this:

$id=$abc[0]->id;
dferenc
  • 7,637
  • 12
  • 39
  • 46
Mosin
  • 550
  • 5
  • 15