Difference between revisions of "User:Niaht Nakamichi/PHP Code"
Jump to navigation
Jump to search
m (→is_uuid) |
m (→is_uuid) |
||
Line 3: | Line 3: | ||
function is_uuid($uuid) { | function is_uuid($uuid) { | ||
if (strlen($uuid) !== 36) return false; | if (strlen($uuid) !== 36) return false; | ||
if (strpos($uuid, '-') !== 8) return false; | if (strpos($uuid, '-') !== 8) return false; | ||
if (strpos($uuid, '-', 24) !== false) return false; | |||
if (strpos($uuid, '-', 9) !== 13) return false; | if (strpos($uuid, '-', 9) !== 13) return false; | ||
if (strpos($uuid, '-', 13) !== 13) return false; | |||
if (strpos($uuid, '-', 14) !== 18) return false; | if (strpos($uuid, '-', 14) !== 18) return false; | ||
if (strpos($uuid, '-', 18) !== 18) return false; | |||
if (strpos($uuid, '-', 19) !== 23) return false; | if (strpos($uuid, '-', 19) !== 23) return false; | ||
if (strpos($uuid, '-', 23) !== 23) return false; | |||
if (ctype_xdigit(str_replace('-', '', $uuid)) == false) return false; | if (ctype_xdigit(str_replace('-', '', $uuid)) == false) return false; | ||
return true; | return true; | ||
} | } | ||
</php> | </php> |
Revision as of 13:40, 29 July 2008
is_uuid
<php> function is_uuid($uuid) { if (strlen($uuid) !== 36) return false; if (strpos($uuid, '-') !== 8) return false; if (strpos($uuid, '-', 24) !== false) return false; if (strpos($uuid, '-', 9) !== 13) return false; if (strpos($uuid, '-', 13) !== 13) return false; if (strpos($uuid, '-', 14) !== 18) return false; if (strpos($uuid, '-', 18) !== 18) return false; if (strpos($uuid, '-', 19) !== 23) return false; if (strpos($uuid, '-', 23) !== 23) return false; if (ctype_xdigit(str_replace('-', , $uuid)) == false) return false; return true; } </php>