Results 1 to 3 of 3

Thread: PHP CLI progress bar

  1. #1
    Join Date
    Jun 2009
    Posts
    56

    PHP CLI progress bar

    I want a PHP code that runs through command line. I have seen this once upon a time from my friend but he didn't explained me how he did so. Now I also wanted to know this. Have you ever seen or know simple progress bar code for PHP command line interface (CLI) scripts? Can you provide me if possible?

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: PHP CLI progress bar

    PHP Code:
    function CLIprogressBar($x$t$display)
    {
        if (
    $x == 0)
        {
            if (
    $display== "")
                echo 
    "Progress: ";
            else if (
    $display != "none")
                echo 
    $display;
            echo 
    "|";
        }
        else
        {
            for (
    $position 106$position >= 0$position--)
            {
                echo 
    "\010";
            }
        }
        for (
    $position 0$position <= 100$position++)
        {
            if (
    $position <= ($x $t 100))
                echo 
    "*";
            else
                echo 
    " ";
        }
        echo 
    "| 100%";
        if (
    $x == $t)
        {
            echo 
    "\n";
        }


  3. #3
    Join Date
    Nov 2008
    Posts
    1,054

    Re: PHP CLI progress bar

    Here is what I have seen:

    PHP Code:
    function myPHPCode ($i$tot$lbl="Progress: "$temp=5) {
        if (
    $i == 0) {
             echo 
    $lbl;
             echo 
    "| 0%";
         } else {
             
    $pos = ($i $tot 100);
              if (
    fmod($pos$temp) == ) {
                  if (
    $pos >= 10 ) echo "\010";
                  if (
    $pos == 100 ) echo "\010";
                   echo 
    "\010\010\010";
                   echo 
    "| $pos%";
               }
           }
           if (
    $i == $tot) echo "\n";


Similar Threads

  1. Tracking Project Progress
    By Sam_Sung in forum Microsoft Project
    Replies: 10
    Last Post: 08-12-2011, 08:45 PM
  2. I cannot see the progress bar in the Status Bar
    By Allinone in forum Technology & Internet
    Replies: 3
    Last Post: 27-02-2011, 06:05 AM
  3. Windows 7 is now progress or not
    By SajalSOFT in forum Operating Systems
    Replies: 4
    Last Post: 09-12-2010, 07:29 AM
  4. Animated GIF Progress Bar
    By Nawvin in forum Software Development
    Replies: 3
    Last Post: 16-07-2009, 09:11 AM
  5. Initialize a progress bar in C++
    By Chrisch in forum Software Development
    Replies: 3
    Last Post: 09-05-2009, 10:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,037,728.89187 seconds with 17 queries