note 79169 added to language.operators.arithmetic
| From: | Anonymous at osu1 dot php dot net | Date: | Wed, 14 Nov 2007 08:30:57 +0000 |
| Subject: | note 79169 added to language.operators.arithmetic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132254@lists.php.net to get a copy of this message | ||
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";
?>
----
Server IP: 208.69.120.35
Probable Submitter: 67.168.161.74
----
Manual Page -- http://www.php.net/manual/en/language.operators.arithmetic.php
Edit -- https://master.php.net/note/edit/79169
Del: integrated -- https://master.php.net/note/delete/79169/integrated
Del: useless -- https://master.php.net/note/delete/79169/useless
Del: bad code -- https://master.php.net/note/delete/79169/bad+code
Del: spam -- https://master.php.net/note/delete/79169/spam
Del: non-english -- https://master.php.net/note/delete/79169/non-english
Del: in docs -- https://master.php.net/note/delete/79169/in+docs
Del: other reasons-- https://master.php.net/note/delete/79169
Reject -- https://master.php.net/note/reject/79169
Search -- https://master.php.net/manage/user-notes.php