在 Code Igniter 下拉数组中获取 while 循环
我正在尝试向下拉列表中添加一组虚拟选项,以使一些 jQuery 代码能够工作。问题是,虽然循环正在工作,但我不知道如何将下拉菜单设置为循环并获取所有 50 个虚拟值,但它只返回第一个值。我知道这就像 PHP 初学者的东西,但循环和数组似乎总是让我感到困惑。
$dummy_value = array('UNASSIGNED');
while ($i <= 50)
{
$dummy_value = "''=> 'null'";
$i++;
}
echo form_dropdown('employee_manager',array('null' => 'Please Select A Manager', $dummy_value)); ?>
理想情况下,我希望 form_dropdown
包含 50 个 ''=>;空值。理论上,我们可以将整个数组(包括第一个选项)添加到循环或变量中(我认为)
I'm trying to add a set of dummy options to my dropdown to make some jQuery code work. The problem is that although the loop is working I can't figure out how to set the drop down to loop though and get all 50 dummy values it just returns the first one. I know this is like beginner PHP stuff but loops and arrays seem to always be confusing to me.
$dummy_value = array('UNASSIGNED');
while ($i <= 50)
{
$dummy_value = "''=> 'null'";
$i++;
}
echo form_dropdown('employee_manager',array('null' => 'Please Select A Manager', $dummy_value)); ?>
Ideally I want the form_dropdown
to contain 50 of ''=> null
vaules. In theory we could add the whole array including the first option to the loop or a variable (I think)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)