Eric Scheid (founder of the excellent IAWiki) shot me a line with a more efficient and much sleeker version of my random hex code straight after I posted it, so here it is!
function random_hex() {
$color = '';
for ($c = 0; $c < 6; $c++) {
$i = rand(0, 15);
$color .= substr("0123456789ABCDEF", $i, 1)
}
$color = '#' . $color;
return $color;
}
Thanks Eric!