NYCPHP Meetup

NYPHP.org

[nycphp-talk] CLI output question

Dan Cech dcech at phpwerx.net
Wed Aug 17 16:53:21 EDT 2005


Joel,

I played a little with your spinner and couldn't get it to work 
properly.  I did come up with this though, which works on both my WinXP 
laptop and Linux dev server:

function progress()
{
   static $spinnerpos = 0;
   static $spinner = '-';
   $spinners = array('-','\\','|','/');

   echo $spinner;
   flush();

   $spinnerpos = ($spinnerpos+1)%4;
   $spinner = "\x8".$spinners[$spinnerpos];
}

Dan

Joel De Gan wrote:
> here is one I made the other day for doing a spin-cursor on FTP
> transfers:
> 
> // just call with no arguments inside a loop.
> function progress(){
> 	global $spinnerpos;
> 	$spinner = array("/","-","\\","\\|","/","-","\\","\\|");
> 	passthru("printf \"\\b\"".$spinner[$spinnerpos] ." ");
> 	$spinnerpos=($spinnerpos +1)%8;
> }
> 
> Cheers.
> -joel



More information about the talk mailing list