<?php
function verificaContas($contas) {
$arrContas = explode(",", $contas); $sucesso = true;
foreach($arrContas as $conta) {
$sucesso = false;
break;
}
}
return $sucesso;
}
echo verificaContas("1,3,55,22,66,22,66") ? "OK" : "NOK";
echo verificaContas(",1,3,55,22,66,22,66") ? "OK" : "NOK";
echo verificaContas("1,3,55,22,66,22,66,") ? "OK" : "NOK";
echo verificaContas("1,3,55,22,66,g22,66") ? "OK" : "NOK";
?>
PD9waHAKCmZ1bmN0aW9uIHZlcmlmaWNhQ29udGFzKCRjb250YXMpIHsKICAkYXJyQ29udGFzID0gZXhwbG9kZSgiLCIsICRjb250YXMpOwogICRzdWNlc3NvID0gdHJ1ZTsKICBmb3JlYWNoKCRhcnJDb250YXMgYXMgJGNvbnRhKSB7CglpZiAoIWlzX251bWVyaWMoJGNvbnRhKSl7CgkJJHN1Y2Vzc28gPSBmYWxzZTsKCQlicmVhazsKCX0KICB9CiAgcmV0dXJuICRzdWNlc3NvOwp9CgplY2hvIHZlcmlmaWNhQ29udGFzKCIxLDMsNTUsMjIsNjYsMjIsNjYiKSA/ICJPSyIgOiAiTk9LIjsKZWNobyB2ZXJpZmljYUNvbnRhcygiLDEsMyw1NSwyMiw2NiwyMiw2NiIpID8gIk9LIiA6ICJOT0siOwplY2hvIHZlcmlmaWNhQ29udGFzKCIxLDMsNTUsMjIsNjYsMjIsNjYsIikgPyAiT0siIDogIk5PSyI7CmVjaG8gdmVyaWZpY2FDb250YXMoIjEsMyw1NSwyMiw2NixnMjIsNjYiKSA/ICJPSyIgOiAiTk9LIjsKCj8+