您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何将表单输入数组转换为PHP数组

如何将表单输入数组转换为PHP数组

它们已经在数组中:$name是数组,是这样$email

因此,您需要做的就是添加一些处理以攻击两个阵列:

$name = $_POST['name'];
$email = $_POST['account'];

foreach( $name as $key => $n ) {
  print "The name is ".$n." and email is ".$email[$key].", thank you\n";
}

要处理更多输入,只需扩展模式:

$name = $_POST['name'];
$email = $_POST['account'];
$location = $_POST['location'];

foreach( $name as $key => $n ) {
  print "The name is ".$n.", email is ".$email[$key].
        ", and location is ".$location[$key].". Thank you\n";
}
php 2022/1/1 18:14:43 有391人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶