我试图做一个非常简单的形式,在浏览器上用两个输入键入名称,然后在我的php中有一个多维关联数组。我要做的是验证我的名字和姓氏输入中的type作为数组中的值存在。我拥有的代码如下所示。.感谢您的帮助。
<body>
<form method="post">
Name: <input type="text" name="frontname">
<br><br>
Lastname: <input type="text" name="lastname" id="">
<br><br>
<input type="submit" name="submit" value="Search!">
</form>
<?php
if (isset($_POST['submit'])) {
$name = $_POST['frontname'];
$lname = $_POST['lastname'];
$found = false;
$persons = [
[
'frontname' => 'Jacky',
'lastname' => 'Chan'
],
[
'frontname' => 'Bruce',
'lastname' => 'Willis'
],
[
'frontname' => 'Jacob',
'lastname' => 'Yaacob'
]
];
foreach($persons as $person) {
foreach($person as $eachPerson) {
echo "$eachPerson ";
}
}
}
?>
</body>