Jump to content

Printing data


ShaolinF

Recommended Posts

Hi Guys

 

I have a for loop which prints out 1 to 10. See code below:

 

for ($i=10;i<10;i++){
   echo $i;
}

 

It prints out as follows:

 

1

2

3

4

.....

 

How can I code it so that the html doesnt print out each integer on a seperate line but rather repaces the first value ? For example:

 

The script outputs "1", when the loop runs the second time it deletes the "1" and replaces it with "2".

Link to comment
https://forums.phpfreaks.com/topic/139431-printing-data/
Share on other sites

well if I have 1000s of integers to loop through then its going to slow the browser down if it prints out each integer on its own line.

 

 

no, the line breaks won't matter, at all, that's static html. Any loop going hrough thousands of times will slow down the process, not matter if its echoing or not.

Link to comment
https://forums.phpfreaks.com/topic/139431-printing-data/#findComment-729369
Share on other sites

well if I have 1000s of integers to loop through then its going to slow the browser down if it prints out each integer on its own line.

 

but ... okie

 

suppose you are searching 101 in those 1000 integer then you will loop to 1000 integer ?????

NO!!

 

because when your script spot the 101 value it should break the loop and come out ... it will save time also.

 

But still if u want to add simple loop to delay then you don't need to print and if you are have such a big loop then you have to keep some check else it will slow down the response.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/139431-printing-data/#findComment-729777
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.