Skip to content

Instantly share code, notes, and snippets.

@caneco
Created June 27, 2019 06:53
Show Gist options
  • Save caneco/1f99346ff0c19b86af2b824449f84ad1 to your computer and use it in GitHub Desktop.
Save caneco/1f99346ff0c19b86af2b824449f84ad1 to your computer and use it in GitHub Desktop.
PHP Insights // terminal loading PoC
<?php
$speed = 20e4;
$pointer = 0;
$square = '◼';
$loading = [
array(
"\033[0;32m{$square}\033[0m", // green
"\033[1;33m{$square}\033[0m", // yellow
"\033[0;31m{$square}\033[0m", // red
),
array(
"\033[0;31m{$square}\033[0m", // red
"\033[0;32m{$square}\033[0m", // green
"\033[1;33m{$square}\033[0m", // yellow
),
array(
"\033[1;33m{$square}\033[0m", // yellow
"\033[0;31m{$square}\033[0m", // red
"\033[0;32m{$square}\033[0m", // green
),
];
for ($i=0 ; $i<=100 ; $i++) {
echo implode(' ', $loading[$pointer++]);
if ($pointer > 2) {
$pointer = 0;
}
echo "\033[5D";
usleep($speed);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment