Created
June 27, 2019 06:53
-
-
Save caneco/1f99346ff0c19b86af2b824449f84ad1 to your computer and use it in GitHub Desktop.
PHP Insights // terminal loading PoC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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