+ 1
How to loop array in array?
I'm using laravel and want to loop data from controller in template. Controller: $post=Post::all(); $data = array (); foreach($posts as $post){ $image=getImage(post->id); $obj=array( "post"=>$post, "image"=>$image); array_push($data, $obj); } In template/blade I would like to: foreach data foreach data["images"] and so on. I've tried several things, but could not figure it out yet. So how would you loop? Asuming 1 post with several images.
1 Antwort
0
foreach($posts as $post) {
$images = $post["images"];
foreach($images as $image) {
// do something
}
}