【问题标题】:Laravel Get Input Value from arrayLaravel 从数组中获取输入值
【发布时间】:2014-01-08 16:29:27
【问题描述】:

以下代码在数组中获取复选框值的正确语法是什么

这里是复选框数组:

@foreach($p->products as $pp)                        
     <input type="checkbox" name="product[]" value="{{ $pp->name }}"> {{ $pp->name }}<br />                            
@endforeach

这就是我获得价值的方式

Input::get('product', 0) // this part how can i get the value from checkbox array if the user select more than one?

【问题讨论】:

    标签: arrays checkbox laravel


    【解决方案1】:

    你可以这样做:

    $products = Input::get('product'); // Returns an array of values from the form
    
    foreach ($products as $product)
    {
       echo $product;
    }
    

    return $product; // Get them as an json
    

    【讨论】:

      猜你喜欢
      • 2015-08-30
      • 2016-09-30
      • 2011-02-26
      • 1970-01-01
      • 2018-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多