Firstname *
<input class="input100" type="text" name="name[]" placeholder="Enter Your First Name ">
foreach($_POST['name'] as $value)
{$_SESSION['name'] = array($value);}
我可以在提交表单之前输入多个名称。 我需要保存在数组中输入的所有名称,以便以后将它们移动到数据库。我该怎么办?
答案 0 :(得分:0)
使用以下php代码: -
<?php
// $nameInputDataArray will contain the array of names from name[] input fields.
$nameInputDataArray = isset($_POST['name'])? $_POST['name']:array();
foreach ($nameInputDataArray as $name){
// now you can access the names one by one.
echo $name;
}
// or all the names can be returned as , separated string using implode()
echo implode ( "," , $nameInputDataArray );
?>