I have a string $s="one\rtwo\rthree\rfour\rfive"
and when I do print $s
I expect to see five
only because the linefeed resets the line.
Instead I seem to be seeing one two three four five
.
What's going on?
If you want to rewrite a line in a console window (like it appears you are trying to do) you can do something like this:
#!/c/PHP/php-7.0/php.exe
<?php
for($i = 0; $i < 100; $i++){
fwrite(STDOUT, "\r$i%");
}
or if you want only the last portion of a string separated by Carriage returns you can do something like this:
$endVal = end(explode("\r", $s));
print($endVal);