if empty $_POST assign value in foreach loop

后端 未结 5 582
南笙
南笙 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:12

    If I understood you correctly, what you are trying to do is this:

    foreach ( $_POST as $key => $value ) {
        if(empty($value))
            $_POST[$key] = 'This is an unanswered question!';
    }
    

    But this cannot work due to the fact that empty values aren't posted from the form.

提交回复
热议问题