Skip to content

Instantly share code, notes, and snippets.

@tim-trulia
Forked from WizardOfArc/blinky.php
Created December 5, 2012 18:14
Show Gist options
  • Select an option

  • Save tim-trulia/4218081 to your computer and use it in GitHub Desktop.

Select an option

Save tim-trulia/4218081 to your computer and use it in GitHub Desktop.
A little cutesy command line animation
<?php
/**
* Blinky is a little ASCII animation inspired by
* Shane Harter's "Progress Display for PHP CLI scripts"
* see: https://gist.github.com/4211173
* this one is written by Azi Crawford forked by Tim Correia
**/
define('BLINKS', array( 'O.O', 'O.o', 'O.-', 'O.o', 'O.O', 'o.O', '-.O', 'o.O', 'O.O', 'o.o', '-.-', 'o.o') );
function draw_blink ($counter){
$frame = $counter % 12;
$blink = BLINKS[$frame];
echo str_repeat("\010", 50);
echo str_pad($blink, 50, ' ', STR_PAD_LEFT);
}
echo str_repeat("\n", 10);
for ($i=0; $i<100; $i++) {
draw_blink($i);
usleep(125000);
}
echo str_repeat("\010", 50);
echo str_repeat(' ', 50) . PHP_EOL;
@WizardOfArc
Copy link
Copy Markdown

Warning: Constants may only evaluate to scalar values in **********/blinky.php on line 9

perhaps we can just have $blink_array instead of defining a constant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment