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]) { //Откатить транзакцию } } } 
  • collect terms via or - splash58
  • Do you really need to terminate up to three? Those. one condition is violated - terminate once. Three conditions violated - terminate three times? Suppose this terminate gives a message to the user. Then the user can receive one, two or three identical messages? - Sergey
  • it's like return false, the code is no longer executed - Serge Esmanovich
  • If the code beyond the first terminate is not executed, then what does the if after it? So remove the checks, which in principle are never performed. Or, if they are to be executed, correct the errors in the program to make it work. And only then think about simplification. - Sergey
  • @Sergey If you do not verify that the data array will be an error, if you do not verify there is such a key, there will be an error, if you do not check whether the array has a value with the specified key, there will be an error. The bottom line is that if the error is necessary to roll back the transaction, it does terminate, if you remove it, the code will be executed, therefore there will be an error. ie if you leave only one output, then there will be at least 2 errors - Serge Esmanovich

0