PHP $_POST get data array

前端 未结 3 660
臣服心动
臣服心动 2020-12-14 21:21

I\'m trying to do a multiple textbox with the same names.
Here is my code.

HTML

Email 1:

        
3条回答
  •  一个人的身影
    2020-12-14 22:01

    Using [] in the element name

    Email 1:
    Email 2:
    Email 3:

    will return an array on the PHP end:

    $email = $_POST['email'];   
    

    you can implode() that to get the result you want:

    echo implode(", ", $email); // Will output email1@email.com, email2@email.com ...
    

    Don't forget to sanitize these values before doing anything with them, e.g. serializing the array or inserting them into a database! Just because they're in an array doesn't mean they are safe.

提交回复
热议问题