fork download
  1. <?php
  2.  
  3. function verificaContas($contas) {
  4. $arrContas = explode(",", $contas);
  5. $sucesso = true;
  6. foreach($arrContas as $conta) {
  7. if (!is_numeric($conta)){
  8. $sucesso = false;
  9. break;
  10. }
  11. }
  12. return $sucesso;
  13. }
  14.  
  15. echo verificaContas("1,3,55,22,66,22,66") ? "OK" : "NOK";
  16. echo verificaContas(",1,3,55,22,66,22,66") ? "OK" : "NOK";
  17. echo verificaContas("1,3,55,22,66,22,66,") ? "OK" : "NOK";
  18. echo verificaContas("1,3,55,22,66,g22,66") ? "OK" : "NOK";
  19.  
  20. ?>
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
OKNOKNOKNOK