如何获取 Laravel 4 控制器中一系列复选框的值(如
问题描述
我想获取我在 Laravel 4 表单中设置的一系列复选框的值.这是视图中设置复选框的代码:
I would like to get the values for a series of checkboxes I have set up in a Laravel 4 form. Here is the code in the view setting up the checkboxes:
在我的控制器中,我想获取复选框的值并将它们放入一个数组中.我不完全确定如何做到这一点,但我认为它是这样的:
In my controller, I would like to get the values for the checked boxes and put them in an array. I am not exactly sure how to do this, but I assume it is something like:
你能为我提供一个解决方案吗?谢谢你.
Could you provide me with a solution to do this? Thank you.
这是我在控制器中的内容:
This is what I have in the controller:
它没有通过if"循环.如何查看 print_r 的输出以查看 $friends_checked 变量中的内容?
It is not going through the "if" loop. How do I see the output of the print_r to see what's in the $friends_checked variable?
推荐答案
如果复选框是相关的,那么你应该在 name 属性中使用 [].
If checkboxes are related then you should use [] in the name attribute.
这篇关于如何获取 Laravel 4 控制器中一系列复选框的值(如果选中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!