3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [ [ "forename" => "Dave", "surname" => "Wood", "dob" => "23/05/1986", "gender" => "Male", ], ]; function outputr(array $input) { // work out the max length for each field $lengths = []; foreach ($input as $row) { foreach ($row as $key => $value) { if (!isset($lengths[$key])) { $lengths[$key] = 0; } $kl = strlen($key); $vl = strlen($value); $ln = ($kl > $vl) ? $kl : $vl; if ($ln > $lengths[$key]) { $lengths[$key] = $ln; } } } // output the table header foreach ($lengths as $key => $length) { echo "+" . str_repeat("-", $length); } echo "+\n"; foreach ($lengths as $key => $length) { $pad = $length - strlen($key); echo "| {$key}"; echo str_repeat(" ", $length); } echo "|\n"; } outputr($input);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VZcib
function name:  (null)
number of ops:  5
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   53     1        INIT_FCALL                                               'outputr'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Function outputr:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 30
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 30
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 28
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 28
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 27
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
Branch analysis from position: 27
Branch analysis from position: 12
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 28
Branch analysis from position: 30
2 jumps found. (Code = 77) Position 1 = 32, Position 2 = 41
Branch analysis from position: 32
2 jumps found. (Code = 78) Position 1 = 33, Position 2 = 41
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 41
2 jumps found. (Code = 77) Position 1 = 44, Position 2 = 58
Branch analysis from position: 44
2 jumps found. (Code = 78) Position 1 = 45, Position 2 = 58
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
Branch analysis from position: 41
Branch analysis from position: 30
filename:       /in/VZcib
function name:  outputr
number of ops:  61
compiled vars:  !0 = $input, !1 = $lengths, !2 = $row, !3 = $value, !4 = $key, !5 = $kl, !6 = $vl, !7 = $ln, !8 = $length, !9 = $pad
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   16     1        ASSIGN                                                   !1, <array>
   18     2      > FE_RESET_R                                       $11     !0, ->30
          3    > > FE_FETCH_R                                               $11, !2, ->30
   19     4    > > FE_RESET_R                                       $12     !2, ->28
          5    > > FE_FETCH_R                                       ~13     $12, !3, ->28
          6    >   ASSIGN                                                   !4, ~13
   20     7        ISSET_ISEMPTY_DIM_OBJ                         0  ~15     !1, !4
          8        BOOL_NOT                                         ~16     ~15
          9      > JMPZ                                                     ~16, ->12
   21    10    >   ASSIGN_DIM                                               !1, !4
         11        OP_DATA                                                  0
   23    12    >   STRLEN                                           ~18     !4
         13        ASSIGN                                                   !5, ~18
   24    14        STRLEN                                           ~20     !3
         15        ASSIGN                                                   !6, ~20
   25    16        IS_SMALLER                                               !6, !5
         17      > JMPZ                                                     ~22, ->20
         18    >   QM_ASSIGN                                        ~23     !5
         19      > JMP                                                      ->21
         20    >   QM_ASSIGN                                        ~23     !6
         21    >   ASSIGN                                                   !7, ~23
   27    22        FETCH_DIM_R                                      ~25     !1, !4
         23        IS_SMALLER                                               ~25, !7
         24      > JMPZ                                                     ~26, ->27
   28    25    >   ASSIGN_DIM                                               !1, !4
         26        OP_DATA                                                  !7
   19    27    > > JMP                                                      ->5
         28    >   FE_FREE                                                  $12
   18    29      > JMP                                                      ->3
         30    >   FE_FREE                                                  $11
   34    31      > FE_RESET_R                                       $28     !1, ->41
         32    > > FE_FETCH_R                                       ~29     $28, !8, ->41
         33    >   ASSIGN                                                   !4, ~29
   35    34        INIT_FCALL                                               'str_repeat'
         35        SEND_VAL                                                 '-'
         36        SEND_VAR                                                 !8
         37        DO_ICALL                                         $31     
         38        CONCAT                                           ~32     '%2B', $31
         39        ECHO                                                     ~32
   34    40      > JMP                                                      ->32
         41    >   FE_FREE                                                  $28
   38    42        ECHO                                                     '%2B%0A'
   40    43      > FE_RESET_R                                       $33     !1, ->58
         44    > > FE_FETCH_R                                       ~34     $33, !8, ->58
         45    >   ASSIGN                                                   !4, ~34
   42    46        STRLEN                                           ~36     !4
         47        SUB                                              ~37     !8, ~36
         48        ASSIGN                                                   !9, ~37
   44    49        NOP                                                      
         50        FAST_CONCAT                                      ~39     '%7C+', !4
         51        ECHO                                                     ~39
   45    52        INIT_FCALL                                               'str_repeat'
         53        SEND_VAL                                                 '+'
         54        SEND_VAR                                                 !8
         55        DO_ICALL                                         $40     
         56        ECHO                                                     $40
   40    57      > JMP                                                      ->44
         58    >   FE_FREE                                                  $33
   49    59        ECHO                                                     '%7C%0A'
   51    60      > RETURN                                                   null

End of function outputr

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.28 ms | 1411 KiB | 16 Q