dpluscc
dpluscc

Reputation: 600

@foreach loop in Laravel 4

Anyone see any reasons why this wouldn't work in laravel 4? I figured I would check here before posting on github.

In the controller:

return View::make('home.index')
->with('bcrumbs', array("home.index" => "Home","home.privacy" =>"Privacy Policy"))

In the template:

@foreach ($bcrumbs as $k => $elem}
  <li><a href='{{ URL::route($k) }}'>{{ $elem }}</a></li>
@endforeach

Even if I remove any processing within the foreach and just write "hi", it is a total failure. Chrome reports:

Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.

Upvotes: 1

Views: 2662

Answers (2)

sidneydobber
sidneydobber

Reputation: 2910

This is not an answer to the problem in question but I got an ERR_EMPTY_RESPONSE with Laravel 4 on Ubuntu Server 12.04, the reason I'm posting this is that I ended up here so someone might find this usefull. The problem for me was the use of PHP's empty() function. Just changed this to if($your_var != null), this fixed my problem.

Upvotes: 0

nicoschneider
nicoschneider

Reputation: 86

I don't know if it's intentional, but you have mis-matched braces: @foreach ($bcrumbs as $k => $elem}: you're opening with ( and (not) closing with } … maybe that's it!

Upvotes: 1

Related Questions