Q:

Run function when if statement is true (For Loop)

I have one issue that I can't solve. So I have for loop.
So here is little code:
  for ($i=0;$i<3;$i++) {
      $int = $i + 1;
      if($sms->mobio_check($servID,$request->input("code$int"))) {
          continue;
          $cart->success($product->id,$product->server->name);
      } else {
          return redirect()->to(route('mcCheckoutFailed'))->withErrors(['codeError'=>__('messages.invalidCode',['input'=>$int])]);
      }
  }

I want if three ifs return true to run function $sms->success();. 
What is wrong here?

A:

You could rely on the fact that if the loop finished, then it's OK, any failures will cause the return in the loop to exit...
for ($i=0;$i<3;$i++) {
      $int = $i + 1;
      if( ! $sms->mobio_check($servID,$request->input("code$int"))) {
          return redirect()->to(route('mcCheckoutFailed'))->withErrors(['codeError'=>__('messages.invalidCode',['input'=>$int])]);
      }
}

$cart->success($product->id,$product->server->name);

