Created
November 15, 2011 19:17
-
-
Save kirkegaard/1368025 to your computer and use it in GitHub Desktop.
holmans spark in php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
$ticks = array('▁','▂','▃','▄','▅','▆','▇'); | |
$args = explode(',', (($argv[1] == '--stdin') ? fgets(fopen('php://stdin', 'r'), 1024) : $argv[1])); | |
$range = (max($args) - min($args)) + 1; | |
array_map(function($val) use ($ticks, $args, $range) { | |
print $ticks[round((($val - min($args)) / $range) * (count($ticks) - 1))]; | |
}, $args); | |
print "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think that you could change to