我想使用数组打印表单字段的值。我在file1.php,名称和电子邮件中有两个字段,我使用post将其传递给file2.php并将其存储在数组中。
<?php
$name = $_post['name']
$email = $_post['email];
function personal($name, $email) {
$return = array($name, $email);
print_r($return); //Output(Array ( [0] => alisha [1] => alisha@gmail.com )
echo implode('<br>', $return); //Output alisha alisha@gmail.com
?>
当用户使用提交按钮转到上一页时,如何在file1.php中打印这些值 alisha 和 alisha@gmail.com 使用会话和cookie?
<input type=text name=name value="**print alisha here array[0]**">
<input type=text name=email value="**print alisha@gmail.com here array[1]**">
答案 0 :(得分:0)
<input type="text" name="name" value="<?= $return[0]; ?>" />
<input type="text" name="email" value="<?= $return[1]; ?>" />
您只需要回显数组键(名称为0,电子邮件为1)。