Skip to content
Advertisement

Undefined Index Array

I just learning laravel and got this error

route class

calling array on route class using foreach but i got error (undefined index) calling array on route class using foreach but i got error (undefined index)

Advertisement

Answer

You’re using the wrong variable within the foreach scope.

use $post["title"] instead of $posts["title"]

// @foreach ($posts as $post)

$posts: entire array
$post: an item of array
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement