Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Laravel curly braces - Appearing inside of my loop statement

Hi Everyone

I'm using a blade foreach statement, the information from my database is appearing on my webpage but the string data that appears on my webpage is surrounded by {}. How would I fix this?

    public function myProfile(){

        $user = New User;
        $getTheUserID = Auth::user()->id;
        $user = DB::table('sayings')->where('user_id', '=', $getTheUserID)->get();  


            return View::make('profile.myprofile')
                    ->with('user', $user);
    }

My foreach statement

@foreach ($user as $key) {
    {{{ $key->expression }}}
}

@endforeach

You have 3 curly braces, need only 2

Hi Haunguyen,

I appreciate the reply but I've changed my curcly braces to two and it still is showing {} around what I'm outputting

1 Answer

Hi there!

Blade does not need the block curly braces, change you code from this:

 @foreach ($user as $key) {
   {{{ $key->expression }}}
 }

 @endforeach

to this:

 @foreach ($user as $key) 

   {{{ $key->expression }}}

@endforeach

and you should be fine, cheers ;)