3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function generateHexKey($startColor = '000', $range = 3) { $length = strlen($startColor); $range = (filter_var($range, FILTER_SANITIZE_NUMBER_INT) != '') ? filter_var($range, FILTER_SANITIZE_NUMBER_INT) : 3; $i = 0; $key = ''; for($j=$length; $j<6; $j++) { $key .= ($startColor{$i}+$range); $range = (($range-1) != 0) ? ($range-1) : ($range+1); } return $startColor . $key; } echo generateHexKey();
Output for 5.5.0 - 7.3.0rc4
000321