3
Good afternoon guys, I’m having a difficulty, where I need to access an element of an array of OBJECTS, I’m not being able to access with foreach, or for. I need your help!
The array of objects:
Array
(
[0] => stdClass Object
(
[pk] => 1343200701115549070
)
[1] => stdClass Object
(
[pk] => 1339248324134135231
)
[2] => stdClass Object
(
[pk] => 1338844272896371640
)
[3] => stdClass Object
(
[pk] => 1338841774089501872
)
[4] => stdClass Object
(
[pk] => 1338838365890273563
)
I need to take the values of "pk" to put in another variable. To complement the explanation, this array is a json_encode file, where I open the file and turn it into json_decode:
$file = new SplFileObject($caminho);
while (!$file->eof()) {
$id_line1 = $file->fgets();
}
$id_line = json_decode($id_line1);
Vlw hug!!
Make a foreach and call the property so
$item->pk
– rray