if empty $_POST assign value in foreach loop

后端 未结 5 588
南笙
南笙 2020-12-20 10:57

Hi want to build a program which creates surveys. I couldn\' t figure out how can i assign value for a question which is unanswered. Thank you for your helps.



        
5条回答
  •  清歌不尽
    2020-12-20 11:22

    Your code doesn't make sense, try this:

    $dizi = array();
    foreach($_POST as $key => $value) {
        if (empty($value)) {
            $value = 'your value';
        }
        $dizi[$key] = $value;
    }
    

提交回复
热议问题