Jump to content

ob_flush() php - Delete old values and view last


Alex_isback

Recommended Posts

Hello everyone

I use Curl and php 7, is it possible while unloading data view only last result and delete the previous ones (ob_flush())?

 

Quote

Processing....images  [Pagina#1/1 - Foto#2/7] Processing....images  [Pagina#1/1 - Foto#3/7] Processing....images  [Pagina#1/1 - Foto#4/7] Processing....images  [Pagina#1/1 - Foto#5/7] Processing....images  [Pagina#1/1 - Foto#6/7] Processing....images  [Pagina#1/1 - Foto#7/7]

example:

Clear everyone except last

Quote

Processing....images  [Pagina#1/1 - Foto#7/7]

sshot-1.png.9db5f83076ea0dd917f255da22a347f5.png

 

for ($i=0;$i<count($str[1]);$i++) {
			//echo "\rScaricamento in corso... [Pagina#".
			($z+1)."/".$pages." - Foto#".(++$u)."/".$pagesnum[1]."]";
			if (!file_exists($folder.'_'.$u.'_'.$images.'.jpg')) 
            file_put_contents($folder.'_'.$u.'_'.$images.'.jpg', get('https://m.media-amazon.com/images/M/'.$str[1][$i].$str[2][$i].'jpg'));
			
			
			
			echo "[Pagina#".($z+1)."/".$pages." - Foto#".($u)."/".$pagesnum[1]."]" . '  <b style="color:red;">Processing....images</b>&nbsp;&nbsp;' ;
							ob_flush(); # http://php.net/ob_flush
							flush(); # http://php.net/flush
							sleep(1); # http://php.net/sleep
						
			
			
		}

 

Link to comment
Share on other sites

You can't echo something, have it displayed, then remove it.  Once the content has been sent to the browser for display it's there.

Trying to stream content as a progress indicator is already questionable.  It may or may not working depending on what kind of software / buffers are involved in the connection.

If you want to progress indication then the ideal thing to do would be to run your tasks as background requests using fetch() and update a display with the progress information as they complete.

 

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.