Skip to content

Instantly share code, notes, and snippets.

@nielslange
Created April 5, 2019 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nielslange/8cebdfcd273dc257a972d1121744848e to your computer and use it in GitHub Desktop.
Save nielslange/8cebdfcd273dc257a972d1121744848e to your computer and use it in GitHub Desktop.
Check if a string only contains letters and numbers
<?php
if ( ctype_alnum( $input ) ) {
echo $input . ' only contains letters and numbers.';
} else {
echo $input . ' does not only contains letters and numbers.';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment