PHP Port =D
KorvinSzanto opened this issue · comments
function spark($numbers,$delimiter = ',') {
$ticks = array(▁,▂,▃,▄,▅,▆,▇);
$sorted = explode($delimiter,$numbers);
sort($sorted);
foreach (explode($delimiter,$numbers) as $i => $tick)
$out .= $ticks[round(($tick / ($sorted[count($sorted)-1] == 0 ? 1 : $sorted[count($sorted)-1])) * (count($ticks)-1))];
return $out;
}
Thought it'd be fun to port to PHP so I did!
It's not so much a port as it is a recreation, tell me what you think.
EX: echo spark("0 0 1 2 3 0 0",' ');
produces ▁▁▃▅▇▁▁
Looks sharp; I've seen a lot of Python and Ruby samples floating around too. Goes to show that a higher-level language can be much more terse. :)