note 79169 deleted from language.operators.arithmetic by betz

From: Date: Wed, 14 Nov 2007 10:29:37 +0000
Subject: note 79169 deleted from language.operators.arithmetic by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-132261@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- Here's a slick little trick, very useful for CLI scripts to show processing taking place with a spinner... #!/usr/bin/php -q <?php //because I'm slick like that, we'll use some fancy ASCII escape codes. //http://www.cs.csubak.edu/Tables_Charts/VT100_Escape_Codes.html define('ESC', 27); printf( "%c[2J", ESC ); //clear screen //note how the '-' is at [1], not [0] $cursorArray = array('/','-','\\','|','/','-','\\','|'); echo "Processing: "; printf( "%c7", ESC ); //save cursor position for ($count = 1; $count <= 30; $count++) { //note that $i is all self contained. printf("%c8(".$cursorArray[ (($i++ > 7) ? ($i = 1) : ($i % 8)) ].") %02d", ESC, $count); //restore cursor position and print sleep(1); } echo "\nDone.\n"; ?>

« previous php.notes (#132261) next »