PHP | Get input name through $_POST[]

前端 未结 8 1580
长发绾君心
长发绾君心 2020-12-16 19:10

HTML example:

  
8条回答
  •  余生分开走
    2020-12-16 19:52

    You can process $_POST in foreach loop to get both names and their values, like this:

    foreach ($_POST as $name => $value) {
       echo $name; // email, for example
       echo $value; // the same as echo $_POST['email'], in this case
    }
    

    But you're not able to fetch the name of property from $_POST['email'] value - it's a simple string, and it does not store its "origin".

提交回复
热议问题