adv Posted April 16, 2011 Share Posted April 16, 2011 hello i have one issue <?php for($i=0;$i<=10;$i++){ echo $i; } ?> it echoes 0123445678910 but the thing is how i can do it like with numbers to echo just one line and ascendent from 0 to 10 like this " 23 of 10000 viewed " something like that Quote Link to comment https://forums.phpfreaks.com/topic/233896-echo-issue/ Share on other sites More sharing options...
Nuv Posted April 16, 2011 Share Posted April 16, 2011 Hi, Can you please give us some more examples of what you want so that we can understand your problem better. Quote Link to comment https://forums.phpfreaks.com/topic/233896-echo-issue/#findComment-1202329 Share on other sites More sharing options...
adv Posted April 16, 2011 Author Share Posted April 16, 2011 what i`m saying is in a for loop its echoes likes this [adv@localhost tmp]# php aaa showing -> 0 showing -> 1 showing -> 2 showing -> 3 showing -> 4 showing -> 5 showing -> 6 showing -> 7 showing -> 8 showing -> 9 showing -> 10 and the thing is i want to show it just like this [adv@localhost tmp]# php aaa showing -> ascendent from 0 to 10 repeatedly Quote Link to comment https://forums.phpfreaks.com/topic/233896-echo-issue/#findComment-1202334 Share on other sites More sharing options...
maxudaskin Posted April 16, 2011 Share Posted April 16, 2011 <?php for($i=0;$i<=10;$i++){ // You have $i set to 0, going up to 10. (11 rows) echo $i; } Output: 012345678910 <?php $start = //your code here $end = //your code here $total_cnt = //your code here for($i = $start; $i <= $end;$i++){ // Now you have $i as a variable, and the end as a variable // some code here } echo "Displaying $start to $end of $total_cnt rows."; Output (assuming that start is 2, end is 17, and total count is 150: Displaying 2 to 17 of 150 rows. Quote Link to comment https://forums.phpfreaks.com/topic/233896-echo-issue/#findComment-1202369 Share on other sites More sharing options...
adv Posted April 16, 2011 Author Share Posted April 16, 2011 sorry maxudaskin but you understood me wrong :| i dont want to display from a table some lines i just want to show when i execute in linux when i do something like this : <?php for($i=0;$i<=10000;$i++){ echo $i; } ?> i want to show like this [adv@localhost tmp]# php aaa showing -> ascendent from 0 to 10000 to show the increasing numbers in just one line Quote Link to comment https://forums.phpfreaks.com/topic/233896-echo-issue/#findComment-1202381 Share on other sites More sharing options...
devWhiz Posted April 16, 2011 Share Posted April 16, 2011 <?php for($i=0;$i<=10000;$i++){ echo $i."\n"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/233896-echo-issue/#findComment-1202432 Share on other sites More sharing options...
adv Posted April 16, 2011 Author Share Posted April 16, 2011 no CLUEL3SS i`ve put an new line just to show what i did earlier you didn`t read the post Quote Link to comment https://forums.phpfreaks.com/topic/233896-echo-issue/#findComment-1202440 Share on other sites More sharing options...
analog Posted April 16, 2011 Share Posted April 16, 2011 Oh I think I might get what you mean. Is it that you want to show: showing -> ascendent from 0 to 10000 then show: showing -> ascendent from 1 to 10000 on the same line of the command line output? Might not be a good explanation but try this and see if it's right: <?php $start = 0; $end = 1000; $last_line_lemgth = 0; echo 'showing -> ascendent from '; for($i=$start;$i<=$end;$i++) { echo str_repeat("\x08", $last_line_lemgth); //backspace char to clear last line echo "{$i} to {$end}"; sleep(1);// so can see it working $last_line_lemgth = strlen("{$i} to {$end}"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/233896-echo-issue/#findComment-1202443 Share on other sites More sharing options...
adv Posted April 17, 2011 Author Share Posted April 17, 2011 your exactly right analog thanks alot man Quote Link to comment https://forums.phpfreaks.com/topic/233896-echo-issue/#findComment-1202556 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.