<?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"; }
You have javascript disabled. You will not be able to edit any code.