Pixel Everywhere

There are only 10 types of people in this world. Those who know binary and those who don't.

PHP CLI Single Line Display — July 4, 2015

PHP CLI Single Line Display

Tested only on Windows 7 using a PHP command line:

php -f myfile.php

  $exit = false;
  while(!$exit){
    echo 'Enter a value: ';
    $cmd = trim(fgets(STDIN));
    if($cmd == 'q' || empty($cmd)){
      $exit = true;
    }else{
      $dots = '.';
      echo "Loading";
      for($a = 1; $a <= $cmd; $a++){
        usleep(10000);
        $s = "\t" . $dots . "$a%\r";
        echo $s;
        $dots .= '.';
      }
      echo "\n";
    }
  }
  exit;