如何在laravel刀片视图中删除逗号之前的空格?

时间:2017-11-26 12:27:38

标签: php laravel laravel-blade

@foreach($opt as $key => $o)
   @if($o == 1)A @endif
   @if($o == 2)B @endif
   @if($key+1 != count($opt)), @endif
@endforeach

如何显示预期输出A,B,C?

//Current Output       A , B , C        
//Expected Output      A, B, C

1 个答案:

答案 0 :(得分:0)

我发现保持刀片语法的可读性是很痛苦的,所以我在if / else语句中的逗号之前复制了这个词。

所需的输出:

<p>Some text goes here, with this conditional text</p>

刀片结构

<p>Some text goes
    @if($condition)
        here, with this conditional text
    @else
        here
    @endif
</p>