Laravel 5.3 prjects: i have e for loop and an object passed from my controller with property as array
My UserController@edit
return view('user.edit',compact('user'));
My user object have a array like property "Post" so $user->post return an array like
[0]=>'post1',
[1]=>'post2',
... more ...
in my view with BLADE i need to display 7 text field input box as array and fill it with array right value of $user->post property:
@for ($i = 0; $i < 7; $i++)
<input type="text" name="ingredients[]" value="{{ ($user->post)[$i] }}" class="form-control" placeholder="Post title">
@endfor
this return error:
ErrorException in 600ad3d79a7e4216538932fc71b893314cf18166.php line 65:
Undefined offset: 2
the problem is the $i inside value attribute if i replace with 0 or 1 (hardcoded index value) it work but with loop index $i it fails??
any ideas how to indexing array property in a for loop on blade template engine?
note: i cannot user foreach loop.
thx alll
dd($user->post);?