3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_progress_bar($length, $progress, $total, $block = '=', $space = ' ') { $perBlock = $total / $length; $blocks = floor($progress / $perBlock); return str_repeat($block, $blocks) . str_repeat($space, $length - $blocks); } $length = 20; $total = 100; echo get_progress_bar($length, 1, $total) . "\n"; echo get_progress_bar($length, 5, $total) . "\n"; echo get_progress_bar($length, 31, $total) . "\n"; echo get_progress_bar($length, 69, $total) . "\n"; echo get_progress_bar($length, 80, $total) . "\n"; echo get_progress_bar($length, 100, $total) . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cUfOs
function name:  (null)
number of ops:  45
compiled vars:  !0 = $length, !1 = $total
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, 20
   11     1        ASSIGN                                                   !1, 100
   13     2        INIT_FCALL                                               'get_progress_bar'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 1
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        CONCAT                                           ~5      $4, '%0A'
          8        ECHO                                                     ~5
   14     9        INIT_FCALL                                               'get_progress_bar'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 5
         12        SEND_VAR                                                 !1
         13        DO_FCALL                                      0  $6      
         14        CONCAT                                           ~7      $6, '%0A'
         15        ECHO                                                     ~7
   15    16        INIT_FCALL                                               'get_progress_bar'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 31
         19        SEND_VAR                                                 !1
         20        DO_FCALL                                      0  $8      
         21        CONCAT                                           ~9      $8, '%0A'
         22        ECHO                                                     ~9
   16    23        INIT_FCALL                                               'get_progress_bar'
         24        SEND_VAR                                                 !0
         25        SEND_VAL                                                 69
         26        SEND_VAR                                                 !1
         27        DO_FCALL                                      0  $10     
         28        CONCAT                                           ~11     $10, '%0A'
         29        ECHO                                                     ~11
   17    30        INIT_FCALL                                               'get_progress_bar'
         31        SEND_VAR                                                 !0
         32        SEND_VAL                                                 80
         33        SEND_VAR                                                 !1
         34        DO_FCALL                                      0  $12     
         35        CONCAT                                           ~13     $12, '%0A'
         36        ECHO                                                     ~13
   18    37        INIT_FCALL                                               'get_progress_bar'
         38        SEND_VAR                                                 !0
         39        SEND_VAL                                                 100
         40        SEND_VAR                                                 !1
         41        DO_FCALL                                      0  $14     
         42        CONCAT                                           ~15     $14, '%0A'
         43        ECHO                                                     ~15
         44      > RETURN                                                   1

Function get_progress_bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cUfOs
function name:  get_progress_bar
number of ops:  24
compiled vars:  !0 = $length, !1 = $progress, !2 = $total, !3 = $block, !4 = $space, !5 = $perBlock, !6 = $blocks
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      '%3D'
          4        RECV_INIT                                        !4      '+'
    5     5        DIV                                              ~7      !2, !0
          6        ASSIGN                                                   !5, ~7
    6     7        INIT_FCALL                                               'floor'
          8        DIV                                              ~9      !1, !5
          9        SEND_VAL                                                 ~9
         10        DO_ICALL                                         $10     
         11        ASSIGN                                                   !6, $10
    7    12        INIT_FCALL                                               'str_repeat'
         13        SEND_VAR                                                 !3
         14        SEND_VAR                                                 !6
         15        DO_ICALL                                         $12     
         16        INIT_FCALL                                               'str_repeat'
         17        SEND_VAR                                                 !4
         18        SUB                                              ~13     !0, !6
         19        SEND_VAL                                                 ~13
         20        DO_ICALL                                         $14     
         21        CONCAT                                           ~15     $12, $14
         22      > RETURN                                                   ~15
    8    23*     > RETURN                                                   null

End of function get_progress_bar

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.08 ms | 1403 KiB | 23 Q