3v4l.org

run code in 300+ PHP versions simultaneously
<?php // http://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB function strtocolour($tstr) { $crc = unpack('L', hash('crc32', $tstr, true))[1]; $Hp = $crc / (0xFFFFFFFF / 6); $S = 0.8; // change as desired $V = 0.8; // change as desired $C = $V*$S; $X = $C*(1 - abs(fmod($Hp, 2) - 1)); $m = $V - $C; $i = 1+min(5, intval($Hp)); $comp = [ [$C, $X, 0], [$X, $C, 0], [ 0, $C, $X], [ 0, $X, $C], [$X, 0, $C], [$C, 0, $X]][$i]; $r = intval(255*($m + $comp[0])); $g = intval(255*($m + $comp[1])); $b = intval(255*($m + $comp[2])); return sprintf("#%02X%02X%02X", $r, $g, $b); } function test($tstr) { echo '<span style="color:"'.strtocolour($tstr).'">'; echo htmlspecialchars($tstr); echo '</span>'; } test('I'); test('am'); test('a'); test('fluffy'); test('bunny'); ?>

preferences:
42.18 ms | 402 KiB | 5 Q