
Untitled
By: a guest on
Aug 18th, 2012 | syntax:
PHP | size: 0.46 KB | hits: 23 | expires: Never
<?php
function hex2samp($hex_code)
{
// check if they included a hash.
if(strstr($hex_code, "#"))
{
// if they did, remove it.
$hex_code = str_replace("#", '', $hex_code);
}
// check if its a valid HEX code
if(preg_match('{[^0-9a-f]}', $hex_code))
{
// valid HEX code, provide the user with a SA-MP compatible version.
return $hex_code . "00";
}
else
{
// invalid HEX code, the function will return 0.
return 0;
}
}
?>