First of all, I know this question already exists and already has answers, but I would like to stress in which way my question is different. I have code like this:
$ognjen=array();
foreach($_POST as $key=>$value){
if($key!='prenos'&& $key!='submit'){
if (strrpos($key, '1', -1)){
if(!empty($_POST[$key])){
$uslov=true;//kontrolna promjenljiva
}else{
$uslov=false;
}
if($uslov==true){
$ognjen[]=$value;
}else{
$_SESSION['message']='You must fill out all fields';
unset($_SESSION['message']);
}
}//ovdje ide elseif
}
}
This code doesn't do what's expected.What I want to achieve is if all values of $_POST are set to put them in $ognjen array,if even one misses, none of them should become part of $ognjen array, but all that inside this foreach loop, because there are some other checkings that need to fulfill. And while searching for answers I couldn't find any that fits to my situation. Please help, I feel that this is pretty simple task to do, but I don't know way to do it.