如果输入等于给定的数组,它将回显3次。我只需要给定输入的单个回声结果

时间:2019-03-14 00:12:56

标签: php html5

如果输入等于给定数组,它将回显3次。我只需要给定输入的单个回声结果...

<?php
$arrayName = array('bravo', 'alpha', 'jhony');
foreach ($arrayName as $key) {
    if (isset($_REQUEST['num1']) && $_REQUEST['num1'] == $key) {
        echo "yes". $_REQUEST['num1']. "Available";
    } else {
        echo "Sorry!".$_REQUEST['num1']." is not available";
    }
}
?>

<form action="" method="get" accept-charset="utf-8"> <input type="text" name="num1"> <button type="submit">submit</button> </form>

0 个答案:

没有答案