3v4l.org

run code in 500+ 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 = 25, Position 2 = 34
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 34
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/VKnBs
function name:  execute
number of ops:  36
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        COUNT                                                ~8      !2
         13        FRAMELESS_ICALL_2                min                 ~9      ~8, !0
         14        CAST                                              4  ~10     ~9
         15        ASSIGN                                                       !0, ~10
   18    16        INIT_FCALL                                                   'printf'
         17        SEND_VAL                                                     'PageNumber%3D%25d%2C+CountCommands%3D%25d%0A'
         18        SEND_VAR                                                     !0
         19        COUNT                                                ~12     !2
         20        SEND_VAL                                                     ~12
         21        DO_ICALL                                                     
   19    22        SUB                                                  ~14     !0, 1
         23        FETCH_DIM_R                                          ~15     !2, ~14
         24      > FE_RESET_R                                           $16     ~15, ->34
         25    > > FE_FETCH_R                                                   $16, !3, ->34
   20    26    >   INIT_FCALL                                                   'printf'
         27        SEND_VAL                                                     'Name%3D%25s%2C+Desc%3D%25s%0A'
         28        FETCH_DIM_R                                          ~17     !3, 'name'
         29        SEND_VAL                                                     ~17
         30        FETCH_DIM_R                                          ~18     !3, 'desc'
         31        SEND_VAL                                                     ~18
         32        DO_ICALL                                                     
   19    33      > JMP                                                          ->25
         34    >   FE_FREE                                                      $16
   22    35      > RETURN                                                       null

End of function execute

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
129.64 ms | 487 KiB | 13 Q