Skip to content

Instantly share code, notes, and snippets.

@jheth
Last active December 12, 2015 00:58
Show Gist options
  • Select an option

  • Save jheth/4687672 to your computer and use it in GitHub Desktop.

Select an option

Save jheth/4687672 to your computer and use it in GitHub Desktop.
PHP ANSI Color Control
<?php
echo chr(27) . '[32m' . "This is a green line" . chr(27) . '[0m' . "\n";
echo chr(27) . '[31m' . "This is a red line" . chr(27) . '[0m' . "\n";
function move_right($x) { echo chr(27) . "[{$x}C"; sleep(1); }
function move_left($x) { echo chr(27) . "[{$x}D"; sleep(1); }
function move_up($x) { echo chr(27) . "[{$x}A"; sleep(1); }
function move_down($x) { echo chr(27) . "[{$x}B"; sleep(1); }
move_right(1);
move_right(1);
move_right(1);
move_right(1);
move_right(1);
move_up(1);
move_up(1);
move_up(1);
move_left(1);
move_left(1);
move_left(1);
move_left(1);
move_left(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment