Check if input field value exist in array, if so return to page with an error

前端 未结 2 605
终归单人心
终归单人心 2021-01-27 04:21

I have a form where user insert their names, once they submit the form, the page should check if the name provided already exists, if so, should return with an error, other wise

2条回答
  •  庸人自扰
    2021-01-27 05:11

    Just make use of a multi-level break statement and come out of the loop.

    Something like

    if (count($keys)>0)
        {
            // Add the key to the temp array so its not found again:
            $temp[] = $key;
            // Do something...
            echo '
  • Name already used'; break 3; }
提交回复
热议问题