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 headers foreach ($lengths as $key => $length) { echo "+" . str_repeat("-", $length + 2); } echo "+\n"; foreach ($lengths as $key => $length) { $pad = $length - strlen($key); echo "| {$key} " . str_repeat(" ", $pad); } echo "|\n"; foreach ($lengths as $key => $length) { echo "+" . str_repeat("-", $length + 2); } echo "+\n"; } outputr($input);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rt0Qb
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>
   59     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 = 42
Branch analysis from position: 32
2 jumps found. (Code = 78) Position 1 = 33, Position 2 = 42
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 42
2 jumps found. (Code = 77) Position 1 = 45, Position 2 = 60
Branch analysis from position: 45
2 jumps found. (Code = 78) Position 1 = 46, Position 2 = 60
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 60
2 jumps found. (Code = 77) Position 1 = 63, Position 2 = 73
Branch analysis from position: 63
2 jumps found. (Code = 78) Position 1 = 64, Position 2 = 73
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
Branch analysis from position: 73
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 73
Branch analysis from position: 60
Branch analysis from position: 42
Branch analysis from position: 30
filename:       /in/rt0Qb
function name:  outputr
number of ops:  76
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, ->42
         32    > > FE_FETCH_R                                       ~29     $28, !8, ->42
         33    >   ASSIGN                                                   !4, ~29
   35    34        INIT_FCALL                                               'str_repeat'
         35        SEND_VAL                                                 '-'
         36        ADD                                              ~31     !8, 2
         37        SEND_VAL                                                 ~31
         38        DO_ICALL                                         $32     
         39        CONCAT                                           ~33     '%2B', $32
         40        ECHO                                                     ~33
   34    41      > JMP                                                      ->32
         42    >   FE_FREE                                                  $28
   38    43        ECHO                                                     '%2B%0A'
   40    44      > FE_RESET_R                                       $34     !1, ->60
         45    > > FE_FETCH_R                                       ~35     $34, !8, ->60
         46    >   ASSIGN                                                   !4, ~35
   42    47        STRLEN                                           ~37     !4
         48        SUB                                              ~38     !8, ~37
         49        ASSIGN                                                   !9, ~38
   44    50        ROPE_INIT                                     3  ~41     '%7C+'
         51        ROPE_ADD                                      1  ~41     ~41, !4
         52        ROPE_END                                      2  ~40     ~41, '+'
         53        INIT_FCALL                                               'str_repeat'
         54        SEND_VAL                                                 '+'
         55        SEND_VAR                                                 !9
         56        DO_ICALL                                         $43     
         57        CONCAT                                           ~44     ~40, $43
         58        ECHO                                                     ~44
   40    59      > JMP                                                      ->45
         60    >   FE_FREE                                                  $34
   48    61        ECHO                                                     '%7C%0A'
   51    62      > FE_RESET_R                                       $45     !1, ->73
         63    > > FE_FETCH_R                                       ~46     $45, !8, ->73
         64    >   ASSIGN                                                   !4, ~46
   52    65        INIT_FCALL                                               'str_repeat'
         66        SEND_VAL                                                 '-'
         67        ADD                                              ~48     !8, 2
         68        SEND_VAL                                                 ~48
         69        DO_ICALL                                         $49     
         70        CONCAT                                           ~50     '%2B', $49
         71        ECHO                                                     ~50
   51    72      > JMP                                                      ->63
         73    >   FE_FREE                                                  $45
   55    74        ECHO                                                     '%2B%0A'
   57    75      > RETURN                                                   null

End of function outputr

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.66 ms | 1398 KiB | 16 Q