I quick tip, I would be using a foreach loop to loop through the objects and not an iterator like you've got, i.e.
Code:
$posts = array([objects]);
foreach($posts as $key=>$post_object){
$post_object->object_function();
$posts[$key][change something in the original array] = [];
}