1function random_part() {
2 return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
3}
4
5function randomHEX($amount) {
6 $_result = "";
7 for ($i = 0 ; $i < $amount; $i++) {
8 $_result .= random_part();
9 }
10 return $_result;
11}
12
13//to get a 16 HEX number
14echo randomHEX(8);
15