包含 php 变量的 $_POST[] 数组内爆时出错
我试图在 $_POST[] 中内爆数组。我正在一个循环内执行此操作,该循环在 ~31 个数组中搜索值...$_POST['1']、$_POST['2']、$_POST['3'] 等。
我正在尝试这样做不过
while($i <= $_SESSION['daysInMonth']){
$month = $_SESSION['month'];
$day = $i;
$names = implode(',',$_POST['names_'.$i]);
$region = $_SESSION['region'];
$date = date("Y").'-'.$month.'-'.$day;
echo("$names");
$i++;
,
我收到以下错误:
警告: implode() [function.implode]: 在线 /home/content/r/e/s/reslife4/html/duty/schedule.php 中传递的参数无效15
这就是我创建 $_POST[] 变量的方式:
<?php $i=1; while($i <= $daysInMonth){?>
<table align="center" style="width: 435px">
<tr>
<td class="style1"><p><select name="names_<?php echo($i); ?>[]" multiple="multiple">
<?php foreach($email_array as $arr){ ?>
<option><?php echo($arr); ?></option>
<?php } ?>
</select></p></td>
</tr>
</table>
<?php $i++; }?>
任何人都可以看到我做错了什么吗?
谢谢!
I am trying to implode an array in a $_POST[]. I am doing this inside of a loop which searches for values in ~31 arrays...$_POST['1'], $_POST['2'], $_POST['3'], etc.
I am trying to do this with:
while($i <= $_SESSION['daysInMonth']){
$month = $_SESSION['month'];
$day = $i;
$names = implode(',',$_POST['names_'.$i]);
$region = $_SESSION['region'];
$date = date("Y").'-'.$month.'-'.$day;
echo("$names");
$i++;
}
I am receiving the following error, though:
Warning: implode() [function.implode]: Invalid arguments passed in /home/content/r/e/s/reslife4/html/duty/schedule.php on line 15
This is how I create the $_POST[] variables:
<?php $i=1; while($i <= $daysInMonth){?>
<table align="center" style="width: 435px">
<tr>
<td class="style1"><p><select name="names_<?php echo($i); ?>[]" multiple="multiple">
<?php foreach($email_array as $arr){ ?>
<option><?php echo($arr); ?></option>
<?php } ?>
</select></p></td>
</tr>
</table>
<?php $i++; }?>
Can anyone see what I am doing wrong?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您传递数组以外的其他内容作为 implode 的第二个参数(例如,当未选择任何选项时),您将收到警告。您可以有条件地内爆:
或转换为数组:
If you pass something other than an array as the second argument to implode (say, when no options were selected), you will receive the warning. You can either conditionally implode:
or cast to array: