Reputation: 41605
I was wondering if there's any simple way to modify and add a new index to a given array at CakePHP.
Currently I'm doing a loop like this:
$posts = $this->paginate('Post');
$a=0;
foreach($posts as $post){
$posts[$a]['Read'] = myfunction($post['Post']['id']);
$a++;
}
Thanks.
Upvotes: 0
Views: 152
Reputation: 71939
You do have to loop, but you could use less code:
$posts = $this->paginate('Post');
foreach($posts as $a=>$post){
$posts[$a]['Read'] = myfunction($post['Post']['id']);
}
Upvotes: 2