3v4l.org

run code in 300+ PHP versions simultaneously
<?php function stringValidator($field) { if(!empty($field) && !ctype_alnum($field)) { return "You typed $field: please use only alphanumeric characters"; } return "valid"; // empty or valid } $strings = ["hello", "what_the"]; foreach ($strings as $string) { echo "$string: " , stringValidator($string) , "\n"; }

preferences:
33.38 ms | 404 KiB | 5 Q