if(!is_array($pgrPhy)){ terminate("Please chose physician in Product Interest section" . $item->Pgr_Id); if (!array_key_exist($item->Pgr_Id,$pgrPhy)) { terminate("Please chose physician in Product Interest section" . $item->Pgr_Id); if (!$pgrPhy[$item->Pgr_Id]) { terminate("Please chose physician in Product Interest section" . $item->Pgr_Id); } } } Simplify $ pgrPhy = getPhy () of $ _POST
if(!is_array($pgrPhy)){ //Откатить транзакцию if (!array_key_exist($item->Pgr_Id,$pgrPhy)) { //Откатить транзакцию if (!$pgrPhy[$item->Pgr_Id]) { //Откатить транзакцию } } }