StefanRSA Posted April 7, 2009 Share Posted April 7, 2009 Hi, Have the following code: <?php ob_implicit_flush(true); for($i=0;$i<5;$i++) { $dis=<<<DIS <div style="width:200px; background-color:lime;border:1px; text-align:center;text-decoration:blink;"> $i </div> DIS; echo $dis; sleep(5); //flush(); } ?> This gives me flashing 0 to 4 in seperate line breaks. How do I replace the 0 to "Some text A" 1 to "Some text B" 2 to "Some text C" and so on? Please can anybody help me.... Link to comment https://forums.phpfreaks.com/topic/152941-solved-ob_implicit_flushtrue/ Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Share Posted April 7, 2009 This is one way of doing it... <?php ob_implicit_flush(true); $arrLetters=range('A','F'); for ($i=0;$i<5;$i++) { echo '<div style="width:200px; background-color:lime;border:1px; text-align:center;text-decoration:blink;">Some text '.$arrLetters[$i].'</div>'; sleep(5); //flush(); } ?> Link to comment https://forums.phpfreaks.com/topic/152941-solved-ob_implicit_flushtrue/#findComment-803219 Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Share Posted April 7, 2009 This is another way... <?php ob_implicit_flush(true); $arrLetters=range('A','F'); $arrLetters='Some text '.$arrLetters; for ($i=0;$i<5;$i++) { echo '<div style="width:200px; background-color:lime;border:1px; text-align:center;text-decoration:blink;">'.$arrLetters[$i].'</div>'; sleep(5); //flush(); } ?> Link to comment https://forums.phpfreaks.com/topic/152941-solved-ob_implicit_flushtrue/#findComment-803220 Share on other sites More sharing options...
StefanRSA Posted April 7, 2009 Author Share Posted April 7, 2009 Thanks Yesideez, Ha Ha! This is a typical case of getting exactly what a person is asking for lol! I should actually ask my question correctly! With <?php ob_implicit_flush(true); $arrLetters=range('A','F'); for ($i=0;$i<5;$i++) { echo '<div style="width:200px; background-color:lime;border:1px; text-align:center;text-decoration:blink;">Some text '.$arrLetters[$i].'</div>'; sleep(5); //flush(); } ?> i get "Some Text A Some Text B and so on... With <?php ob_implicit_flush(true); $arrLetters=range('A','F'); $arrLetters='Some text '.$arrLetters; for ($i=0;$i<5;$i++) { echo '<div style="width:200px; background-color:lime;border:1px; text-align:center;text-decoration:blink;">'.$arrLetters[$i].'</div>'; sleep(5); //flush(); } ?> i get S o m e..... I am actually trying to do this.....: "Verifying Data" "Verifying Dates" "Connecting to DB" "Collecting Info" "Verifying Results" That is what I meant by "Some Text A" "Some Text B" and so on. Do I miss anything? Link to comment https://forums.phpfreaks.com/topic/152941-solved-ob_implicit_flushtrue/#findComment-803266 Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Share Posted April 7, 2009 Major LOL with a bit of ROFL You can set up an array manually like this... <?php ob_implicit_flush(true); $arrText=array('Verifying Data','Verifying Dates','Connecting to DB'); for ($i=0;$i<5;$i++) { echo '<div style="width:200px; background-color:lime;border:1px; text-align:center;text-decoration:blink;">'.$arrText[$i].'</div>'; sleep(5); //flush(); } ?> I know that's still pretty much exactly the same but if you're wanting PHP to change them in order with only one item displayed at a time - it can't be done. The server parses the PHP code and throws it to the browser when finished. If you want this to update you'd need to use Javascript but you wouldn't be able to match this up with anything PHP was doing. Link to comment https://forums.phpfreaks.com/topic/152941-solved-ob_implicit_flushtrue/#findComment-803279 Share on other sites More sharing options...
StefanRSA Posted April 7, 2009 Author Share Posted April 7, 2009 Thank You Yesideez! My problem is solved! You R A STAR!!!! Link to comment https://forums.phpfreaks.com/topic/152941-solved-ob_implicit_flushtrue/#findComment-803348 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.