title: PHP console invert scroll when printing multiple lines
body: <p>I'm writing a PHP script (think matrix) that will run on command line only.</p>
  
  <p>At the moment it prints a line of code that ends in a new line, over and over. When the screen fills it begins to scroll with each line. The scroll direction is from the bottom to the top.</p>
  
  <p>Is there anyway using cursor position in a terminal to be able to invert this behaviour and begin printing lines of code at the top of the screen so that the scroll is from top to bottom?</p>
  
  <p><em>Example code:</em></p>
  
  <pre><code>for ($lines=1000;$lines&gt;0;$lines--) {
      echo "this is a basic line of code\n";
  }
  </code></pre>
  
  <p><em>What I'm trying:</em></p>
  
  <pre><code>for ($lines=1000;$lines&gt;0;$lines--) {
      echo "\033[0;0H";        
      echo "\nthis is a basic line of code";
  }
  </code></pre>
  
  <p>This is a very basic example that simulates what I'm trying to achieve - php print a line at position 0,0. Write new line at 0,0, old line moves down one line. When repeated over and over the scroll would then be inverted.</p>
  
  <p>There may be other ways that I'm unaware of to do this other than using <strong><a href="http://wiki.bash-hackers.org/scripting/terminalcodes" rel="nofollow">ANSI</a></strong>?</p>
  
  <p><br>
  <br>
  <em>For the 'terminals will be different depending OS' comment that is bound to appear --- I'm using a mac and it's a fun little project so that's all it needs to support</em></p>