I'd like to get lastdata of value "user_id" from Object $posts bellow.
I can easily get them with foreach, but I need them directly. Already tried some ways as $posts->entities and $posts->entities[0], but nothing.
I can only get them via foreach as example:
foreach ($posts as $post) {
print_r($post);
}
But it would be good if I understand how to get directly.
ArrayCollection {#424 ▼
#entities: array:2 [▼
9 => Post {#348 ▼
#_getterCache: []
#_valueCache: array:1 [▶]
#_structure: Structure {#359 ▶}
#_em: Manager {#211 ▼
#db: Adapter {#203 ▶}
#valueFormatter: ValueFormatter {#212}
#extension: Extension {#205 ▶}
#entityClassNameMap: array:21 [▶]
#entities: array:13 [▼
"XF\Entity\UserPrivacy" => array:2 [▶]
"XF\Entity\UserProfile" => array:2 [▶]
"XF\Entity\UserOption" => array:2 [▶]
"XF\Entity\User" => array:2 [▼
2 => User {#300 ▼
#_getterCache: array:1 [▶]
#_valueCache: array:2 [▶]
#_structure: Structure {#213 ▶}
#_em: Manager {#211}
-_uniqueEntityId: 5
#rootClass: "XF\Entity\User"
#_useReplaceInto: false
#_newValues: []
#_values: array:34 [▼
"user_id" => 2
"username" => "testuser"