3v4l.org

run code in 300+ PHP versions simultaneously
<?php function execute($pageNumber, $pageHeight){ $commands = [ "foo" => ["name" => "foo", "desc" => "Foo Desc"], "fuu" => ["name" => "fuu", "desc" => "Fuu Desc"], "bar" => ["name" => "bar", "desc" => "Bar Desc"], "baa" => ["name" => "baa", "desc" => "Baa Desc"], "blah" => ["name" => "blah", "desc" => "Blah Desc"], "fool" => ["name" => "fool", "desc" => "Fool Desc"], "boof" => ["name" => "boof", "desc" => "boof Desc"], ]; ksort($commands, SORT_NATURAL | SORT_FLAG_CASE); $commands = array_chunk($commands, $pageHeight); $pageNumber = (int) min(count($commands), $pageNumber); printf("PageNumber=%d, CountCommands=%d\n", $pageNumber, count($commands)); foreach($commands[$pageNumber - 1] as $command){ printf("Name=%s, Desc=%s\n", $command["name"], $command["desc"]); } } execute(1, 3); echo "===\n\n"; execute(2, 3); echo "===\n\n"; execute(3, 3);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VKnBs
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'execute'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 3
          3        DO_FCALL                                      0          
   25     4        ECHO                                                     '%3D%3D%3D%0A%0A'
   26     5        INIT_FCALL                                               'execute'
          6        SEND_VAL                                                 2
          7        SEND_VAL                                                 3
          8        DO_FCALL                                      0          
   27     9        ECHO                                                     '%3D%3D%3D%0A%0A'
   28    10        INIT_FCALL                                               'execute'
         11        SEND_VAL                                                 3
         12        SEND_VAL                                                 3
         13        DO_FCALL                                      0          
         14      > RETURN                                                   1

Function execute:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 37
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 37
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/VKnBs
function name:  execute
number of ops:  39
compiled vars:  !0 = $pageNumber, !1 = $pageHeight, !2 = $commands, !3 = $command
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, <array>
   14     3        INIT_FCALL                                               'ksort'
          4        SEND_REF                                                 !2
          5        SEND_VAL                                                 14
          6        DO_ICALL                                                 
   15     7        INIT_FCALL                                               'array_chunk'
          8        SEND_VAR                                                 !2
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $6      
         11        ASSIGN                                                   !2, $6
   16    12        INIT_FCALL                                               'min'
         13        COUNT                                            ~8      !2
         14        SEND_VAL                                                 ~8
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $9      
         17        CAST                                          4  ~10     $9
         18        ASSIGN                                                   !0, ~10
   18    19        INIT_FCALL                                               'printf'
         20        SEND_VAL                                                 'PageNumber%3D%25d%2C+CountCommands%3D%25d%0A'
         21        SEND_VAR                                                 !0
         22        COUNT                                            ~12     !2
         23        SEND_VAL                                                 ~12
         24        DO_ICALL                                                 
   19    25        SUB                                              ~14     !0, 1
         26        FETCH_DIM_R                                      ~15     !2, ~14
         27      > FE_RESET_R                                       $16     ~15, ->37
         28    > > FE_FETCH_R                                               $16, !3, ->37
   20    29    >   INIT_FCALL                                               'printf'
         30        SEND_VAL                                                 'Name%3D%25s%2C+Desc%3D%25s%0A'
         31        FETCH_DIM_R                                      ~17     !3, 'name'
         32        SEND_VAL                                                 ~17
         33        FETCH_DIM_R                                      ~18     !3, 'desc'
         34        SEND_VAL                                                 ~18
         35        DO_ICALL                                                 
   19    36      > JMP                                                      ->28
         37    >   FE_FREE                                                  $16
   22    38      > RETURN                                                   null

End of function execute

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.27 ms | 1008 KiB | 20 Q