3v4l.org

run code in 300+ PHP versions simultaneously
<?php $allowed = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $input = 'abc-def'; $validLen = strspn($input, $allowed); if (strlen($input) !== $validLen) { printf('Input invalid, starting at %s', substr($input, $validLen)); } else { echo 'Input is valid'; }

preferences:
39.9 ms | 406 KiB | 5 Q