I want to know is it possible to change some output for special php cli base application to change some value on terminal not echo new one. for example this is cli application.
#!/usr/bin/env php
<?php
$percent = 0;
for ($i = 0; $i <= 100; $i++) {
echo $percent . "\n";
sleep(1);
$percent++;
}
/**
0
1
...
*/
It’s a simple app to show the user the percentage. So we must update it after each loop in this example, rather than append it. I want to change percent not show new one.
use
\rinstead of\n.\ris a carriage return, it will jump back to the beginning of the line without a newline.This is working on Windows, Linux and MacOS