View Single Post
Old 01-09-2008, 02:26 PM   #4 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

You've already got the problem solved but I see no reason to waste time and energy when it's not necessary. Is there any reason why the following would not suffice?

PHP Code:
$hash 'abc123,1';
if (
preg_match('/\d{1,3}/'$hash$matches))
{
    
$bits = (int) $matches[0];
    
$hex  $bits 4;
    unset (
$matches);

Salathe is offline  
Reply With Quote