using a foreach loop to initialize variables

后端 未结 4 862
抹茶落季
抹茶落季 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 09:03

    Hope this will help, If not may be I have misunderstood the problem.

    Instead of

    $key = stripslashes(filter_input(INPUT_POST, $key)); 
    $insArray[$key] = $key;
    

    Try

    $insArray[$key] =stripslashes(filter_input(INPUT_POST, $key));
    

    Then after the foreach loop

    extract($insArray);
    

提交回复
热议问题