Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 18th, 2012  |  syntax: PHP  |  size: 0.46 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. function hex2samp($hex_code)
  4. {
  5.        
  6.         // check if they included a hash.
  7.         if(strstr($hex_code, "#"))
  8.         {
  9.                 // if they did, remove it.
  10.                 $hex_code = str_replace("#", '', $hex_code);
  11.         }
  12.        
  13.         // check if its a valid HEX code
  14.         if(preg_match('{[^0-9a-f]}', $hex_code))
  15.         {
  16.                 // valid HEX code, provide the user with a SA-MP compatible version.
  17.                 return $hex_code . "00";
  18.         }
  19.         else
  20.         {
  21.                 // invalid HEX code, the function will return 0.
  22.                 return 0;
  23.         }
  24.        
  25. }
  26.  
  27. ?>