Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9300743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:51:07+00:00 2026-06-18T22:51:07+00:00

Lets say my php code is similar to below. . . $range = range(0,

  • 0

Lets say my php code is similar to below. . .

$range = range(0, 5);
foreach ($range as $times) {
if (ob_get_level() == 0) ob_start();
for ($i = 0; $i<1; $i++){
echo "<br>example ".$times;
echo str_pad('',4096)."\n";   
ob_flush();
flush();
sleep(1.2);
}
ob_end_flush();
}

What it displays is. . .

example1
example2
example3
example4
example5

It waits a short period of time before showing the next line, I don’t want to display all five at once, I want to replace example1 with the next one and so on for all five is this possible in php? any answers welcome

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T22:51:09+00:00Added an answer on June 18, 2026 at 10:51 pm

    You Would need to use javascript to replace the element already on the page:

    <p id="ob">1</p>
    <?php
    $range = range(0, 5);
    foreach ($range as $times) {
        if (ob_get_level() == 0) ob_start();
        for ($i = 0; $i<1; $i++){
            echo "<script>document.getElementById('ob').innerHTML ='example$times';</script>";
            echo str_pad('',4096)."\n";
            ob_flush();
            flush();
            sleep(1.2);
        }
        ob_end_flush();
    }
    ?>
    

    Or a much better way would be to use AJAX to poll the server for the next value.

    <?php
    if(isset($_GET['poll'])){
        echo $_GET['poll']+1;
        die;
    }
    ?>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script>
    var value = 0;
    function poll(){
        setTimeout(function(){
            $.ajax({ url: "./test.php?poll="+value,cache: false,
            success: function(data){
                value = data;
                $("#ob").html('example'+value);
                //Next poll
                poll();
            }});
        }, 1200);
    }
    
    $(document).ready(function(){
        poll();
    });
    </script>
    <p id="ob">example0</p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic PHP question, take the code below for example, let's say
Lets say I have some code: <?php echo Hello Everybody!; echo <br/> ; $var1
Lets say I have this code: <?php class hello { var $greeting = hello;
Lets say for example: $(.button).click(function() { $.post(commandrunner.php, { param1: 'value', param2: 'value2', param3: 'value3'
Lets say my URL is: http://www.example.com/news/media-centre/news/17/an-example-news-post/?foo=bar I want to in PHP remove the last
Possible Duplicate: Output array elements randomly with PHP Lets say we have this code:
Example PHP code: <?php $image_attributes = wp_get_attachment_image_src( '8' ); ?> <img src="<?php echo $image_attributes[0];
Lets say, the code looks something like this: if(!$test) { header(Location: somefile.html); ...some PHP
I have a standard Mysqli/php code that echo a list of items. So lets
So lets say i have a block of php code and i have an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.