duaeim2874 2016-10-17 01:40
浏览 192
已采纳

如何在Laravel Views中对来自@foreach的数据进行排序

I know this is possible but I've tried to search from the net but I've never found an answer so if anyone who knows how to push data to array from @foreach using Laravel View please help me. Thanks in advance

Here is the code

@foreach ($fields as $key => $rel)

 {{ $arrayData = array(

    'field_type' =>'$rel->field_type'
 )}}

@endforeach

The error I've receiving is

ErrorException in helpers.php line 519: htmlspecialchars() expects parameter 1 to be string, array given (View: C:\xampp\htdocs\fields.blade.php)

  • 写回答

1条回答 默认 最新

  • dsrnwngq411594 2016-10-17 01:43
    关注

    Remove quote from $rel->field_type

    @foreach ($fields as $key => $rel)
    
     {{ $arrayData = array(
    
        'field_type' =>$rel->field_type
     )}}
    
    @endforeach
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试