2014-01-07 58 views
1

什么是下面的代码正确的语法在一个阵列Laravel从阵列

这里获得的复选框值获取输入值的复选框数组:

@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? 

回答

0

你可以这样做:

$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