Laravel Blade prints unknown values

1

I make use of Laravel 5.3.

I have a variable that returns this value in a var_dump ():

 array(3) {
  [1]=>
  string(5) "10:00"
  [2]=>
  string(5) "10:20"
  [3]=>
  string(5) "11:40"
}

But if I give:

@foreach($variavel as $valor)
    <label for="{{$valor}}"> {{$valor}} </label>
    <input type="checkbox" id="{{$valor}}" name="horario[0][]" />
@endforeach

He printed this out:

<label for="10:00">10:00</label>
<input type="checkbox" id="10:00" name="horario[0][]" />
<label for="10:20">10:20</label>
<input type="checkbox" id="10:20" name="horario[0][]" />
<label for="11:40">11:40</label>
<input type="checkbox" id="11:40" name="horario[0][]" />

And if I do:

@foreach($variavel as $valor)
    <label for="{{print $valor}}"> {{print $valor}} </label>
    <input type="checkbox" id="{{print $valor}}" name="horario[0][]" />
@endforeach

Print this:

10:00 1 10:20 1 11:40 1

I do not understand where this number 1 can come after each value printed, because if you do this print within the PHP tags it does not appear. What could cause this? Could I be clear? ps: between the value and the number 1 is the checbox?

    
asked by anonymous 09.02.2017 / 15:39

1 answer

3

You are using wrong, in the code {{ }} is replaced for :

<?php echo e($horario_livre); ?> 

then the correct code would be:

@foreach($horarios_livres as $horario_livre) 
    {{$horario_livre}}     
@endforeach

No need to put print . When print is placed just to get an idea, the code is generated:

<?php echo e(print $horario_livre); ?> 

The output at the end is a 1 number because print returns an integer, online example .

References:

10.02.2017 / 00:12