Return to Snippet

Revision: 11617
at February 11, 2009 11:37 by duniyadnd


Updated Code
function isHexadecimalString ( $str ) {
  if ( preg_match("/^[a-f0-9]{1,}$/is", $str) ) {
      return true;
  } else {
      return false;
  }
}

Revision: 11616
at February 11, 2009 11:00 by duniyadnd


Initial Code
<?
function isHexadecimalString ( $str ) {
  if ( preg_match("/^[a-f0-9]{1,}$/is", $str) ) {
      return true;
  } else {
      return false;
  }
}
?>

Initial URL


Initial Description
Figure out if the string possesses only hexadecimal characters in the string. If not, fail. Remember, white spaces are not hexadecimal, so make sure you trim() your strings before you send it in or explode your string.

Initial Title
preg_match for Hexadecimal Strings

Initial Tags
php

Initial Language
PHP