3v4l.org

run code in 300+ PHP versions simultaneously
<?php // convert decimal to base 2 without using base_convert or printf $base = 2; $decnum = 23; $num = 23; $stack = array(); while( $num > 0) { $arr[] = $num % $base; // store remainder in array $num = floor($num/$base); // no integer division } var_dump($arr); $wrong = join('',$arr); var_dump($wrong); $cat = join('',array_reverse($arr)); var_dump($cat); printf("%b\n",$decnum); echo base_convert(23,10,2),"\n"; // now using the stack while( $decnum > 0) { array_push($stack,($decnum % $base)); // store remainder on stack $decnum = floor($decnum/$base); // no integer division } while($stack) { echo array_pop($stack); } echo "\n"; // per manual: Note: If you use array_push() to add one element to the array it's better to use $array[] = // because in that way there is no overhead of calling a function. $decnum = 23; while( $decnum > 0) { $stack[] = $decnum % $base; // store remainder on stack $decnum = floor($decnum/$base); // no integer division } while($stack) { echo array_pop($stack); } echo "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 5
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 49
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
2 jumps found. (Code = 44) Position 1 = 67, Position 2 = 62
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 78
Branch analysis from position: 78
2 jumps found. (Code = 44) Position 1 = 80, Position 2 = 70
Branch analysis from position: 80
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
2 jumps found. (Code = 44) Position 1 = 86, Position 2 = 81
Branch analysis from position: 86
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 81
2 jumps found. (Code = 44) Position 1 = 86, Position 2 = 81
Branch analysis from position: 86
Branch analysis from position: 81
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 80, Position 2 = 70
Branch analysis from position: 80
Branch analysis from position: 70
Branch analysis from position: 62
2 jumps found. (Code = 44) Position 1 = 67, Position 2 = 62
Branch analysis from position: 67
Branch analysis from position: 62
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 49
Branch analysis from position: 61
Branch analysis from position: 49
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 5
Branch analysis from position: 15
Branch analysis from position: 5
filename:       /in/6cljQ
function name:  (null)
number of ops:  88
compiled vars:  !0 = $base, !1 = $decnum, !2 = $num, !3 = $stack, !4 = $arr, !5 = $wrong, !6 = $cat
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 2
    4     1        ASSIGN                                                   !1, 23
    5     2        ASSIGN                                                   !2, 23
    6     3        ASSIGN                                                   !3, <array>
    8     4      > JMP                                                      ->13
   10     5    >   MOD                                              ~12     !2, !0
          6        ASSIGN_DIM                                               !4
          7        OP_DATA                                                  ~12
   11     8        INIT_FCALL                                               'floor'
          9        DIV                                              ~13     !2, !0
         10        SEND_VAL                                                 ~13
         11        DO_ICALL                                         $14     
         12        ASSIGN                                                   !2, $14
    8    13    >   IS_SMALLER                                               0, !2
         14      > JMPNZ                                                    ~16, ->5
   13    15    >   INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !4
         17        DO_ICALL                                                 
   14    18        INIT_FCALL                                               'join'
         19        SEND_VAL                                                 ''
         20        SEND_VAR                                                 !4
         21        DO_ICALL                                         $18     
         22        ASSIGN                                                   !5, $18
   15    23        INIT_FCALL                                               'var_dump'
         24        SEND_VAR                                                 !5
         25        DO_ICALL                                                 
   16    26        INIT_FCALL                                               'join'
         27        SEND_VAL                                                 ''
         28        INIT_FCALL                                               'array_reverse'
         29        SEND_VAR                                                 !4
         30        DO_ICALL                                         $21     
         31        SEND_VAR                                                 $21
         32        DO_ICALL                                         $22     
         33        ASSIGN                                                   !6, $22
   17    34        INIT_FCALL                                               'var_dump'
         35        SEND_VAR                                                 !6
         36        DO_ICALL                                                 
   18    37        INIT_FCALL                                               'printf'
         38        SEND_VAL                                                 '%25b%0A'
         39        SEND_VAR                                                 !1
         40        DO_ICALL                                                 
   19    41        INIT_FCALL                                               'base_convert'
         42        SEND_VAL                                                 23
         43        SEND_VAL                                                 10
         44        SEND_VAL                                                 2
         45        DO_ICALL                                         $26     
         46        ECHO                                                     $26
         47        ECHO                                                     '%0A'
   22    48      > JMP                                                      ->59
   24    49    >   INIT_FCALL                                               'array_push'
         50        SEND_REF                                                 !3
         51        MOD                                              ~27     !1, !0
         52        SEND_VAL                                                 ~27
         53        DO_ICALL                                                 
   25    54        INIT_FCALL                                               'floor'
         55        DIV                                              ~29     !1, !0
         56        SEND_VAL                                                 ~29
         57        DO_ICALL                                         $30     
         58        ASSIGN                                                   !1, $30
   22    59    >   IS_SMALLER                                               0, !1
         60      > JMPNZ                                                    ~32, ->49
   27    61    > > JMP                                                      ->66
   28    62    >   INIT_FCALL                                               'array_pop'
         63        SEND_REF                                                 !3
         64        DO_ICALL                                         $33     
         65        ECHO                                                     $33
   27    66    > > JMPNZ                                                    !3, ->62
   30    67    >   ECHO                                                     '%0A'
   33    68        ASSIGN                                                   !1, 23
   34    69      > JMP                                                      ->78
   36    70    >   MOD                                              ~36     !1, !0
         71        ASSIGN_DIM                                               !3
         72        OP_DATA                                                  ~36
   37    73        INIT_FCALL                                               'floor'
         74        DIV                                              ~37     !1, !0
         75        SEND_VAL                                                 ~37
         76        DO_ICALL                                         $38     
         77        ASSIGN                                                   !1, $38
   34    78    >   IS_SMALLER                                               0, !1
         79      > JMPNZ                                                    ~40, ->70
   39    80    > > JMP                                                      ->85
   40    81    >   INIT_FCALL                                               'array_pop'
         82        SEND_REF                                                 !3
         83        DO_ICALL                                         $41     
         84        ECHO                                                     $41
   39    85    > > JMPNZ                                                    !3, ->81
   42    86    >   ECHO                                                     '%0A'
         87      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.7 ms | 1404 KiB | 29 Q