for($reg3=0; $reg3<strlen($str); $reg3++)
{
$reg0 = $str[$reg3];
switch($reg0)
{
case '0': $reg1[] = '0000'; break;
开发者_StackOverflow社区 case '1': $reg1[] = '0001'; break;
case '2': $reg1[] = '0010'; break;
case '3': $reg1[] = '0011'; break;
case '4': $reg1[] = '0100'; break;
case '5': $reg1[] = '0101'; break;
case '6': $reg1[] = '0110'; break;
case '7': $reg1[] = '0111'; break;
case '8': $reg1[] = '1000'; break;
case '9': $reg1[] = '1001'; break;
case 'a': $reg1[] = '1010'; break;
case 'b': $reg1[] = '1011'; break;
case 'c': $reg1[] = '1100'; break;
case 'd': $reg1[] = '1101'; break;
case 'e': $reg1[] = '1110'; break;
case 'f': $reg1[] = '1111'; break;
}
}
$reg1 = join($reg1);
Work with a List, that way you can work dynamic.
精彩评论