<?php $tests = array( "3782-8224-6310-0005", "3782-8224-6310-0005", "3782-S224-6310-W005", "3T82-l224-631k-00f5", ">782-82^4-6@10-00(5", "3?82-8@24-6310-00&%",); foreach ($tests as $element) { str_replace("-","",$element); if (is_numeric($element)) { echo "'{$element}' is valid", PHP_EOL; } else { echo "'{$element}' is NOT valid", PHP_EOL; }}?>
Standard input is empty
'3782-8224-6310-0005' is NOT valid '3782-8224-6310-0005' is NOT valid '3782-S224-6310-W005' is NOT valid '3T82-l224-631k-00f5' is NOT valid '>782-82^4-6@10-00(5' is NOT valid '3?82-8@24-6310-00&%' is NOT valid
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!