using a foreach loop to initialize variables

后端 未结 4 864
抹茶落季
抹茶落季 2021-01-16 08:22

I have built an empty associative array whos keynames refer to submitted post data. I can capture the postdata just fine, but I run into trouble trying to instantiate varia

4条回答
  •  佛祖请我去吃肉
    2021-01-16 08:52

    The solution is change

    $key = stripslashes(filter_input(INPUT_POST, $key));
    

    to

    $$key = stripslashes(filter_input(INPUT_POST, $key));
    

    See http://www.php.net/manual/en/language.variables.variable.php

    Also, recheck your code, which are doing some mistakes..

提交回复
热议问题