Skip to content

Instantly share code, notes, and snippets.

@mathamoz
Created May 27, 2016 20:18
Show Gist options
  • Save mathamoz/6a8b638532d2b3663e216e6f1ffff1f1 to your computer and use it in GitHub Desktop.
Save mathamoz/6a8b638532d2b3663e216e6f1ffff1f1 to your computer and use it in GitHub Desktop.
Find if a string is a double or an integer
<?php
function integerOrDouble($val) {
if (is_numeric($val) && strpos($val, '.')) {
return 'double';
} else if (is_numeric($val)) {
return 'integer';
}
return NULL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment