3v4l.org

run code in 300+ PHP versions simultaneously
<?php $employees = [ [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], [ 'name' => 'John', 'profession' => 'system administrator', 'skills' => [ ['name' => 'bash', 'experience' => 2], ], ], [ 'name' => 'Jane', 'profession' => 'programmer', 'skills' => [ ['name' => 'bash', 'experience' => 3], ['name' => 'php', 'experience' => 2], ['experience' => 0], ], ], [ 'name' => 'Jack', 'profession' => 'system administrator', 'skills' => [], ], ]; $results = []; for ($i = 0; $i < 10000; $i++) { $sum = 0; $count = 0; foreach ($employees as $employee) { if ($employee['profession'] === 'programmer') { foreach ($employee['skills'] as $skill) { if ( isset($skill['name']) && $skill['name'] === 'bash' ) { $sum += $skill['experience']; $count++; } } } } $results[] = $count ? $sum / $count : 0; } echo count($results);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 4
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 26
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 26
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 24
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 24
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 23
Branch analysis from position: 19
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 24
Branch analysis from position: 25
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 31
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 4
Branch analysis from position: 37
Branch analysis from position: 4
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 4
Branch analysis from position: 37
Branch analysis from position: 4
Branch analysis from position: 26
filename:       /in/tn4Rv
function name:  (null)
number of ops:  40
compiled vars:  !0 = $employees, !1 = $results, !2 = $i, !3 = $sum, !4 = $count, !5 = $employee, !6 = $skill
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
  426     1        ASSIGN                                                   !1, <array>
  427     2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->35
  428     4    >   ASSIGN                                                   !3, 0
          5        ASSIGN                                                   !4, 0
  429     6      > FE_RESET_R                                       $12     !0, ->26
          7    > > FE_FETCH_R                                               $12, !5, ->26
  430     8    >   FETCH_DIM_R                                      ~13     !5, 'profession'
          9        IS_IDENTICAL                                             ~13, 'programmer'
         10      > JMPZ                                                     ~14, ->25
  431    11    >   FETCH_DIM_R                                      ~15     !5, 'skills'
         12      > FE_RESET_R                                       $16     ~15, ->24
         13    > > FE_FETCH_R                                               $16, !6, ->24
  433    14    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~17     !6, 'name'
         15      > JMPZ_EX                                          ~17     ~17, ->19
  434    16    >   FETCH_DIM_R                                      ~18     !6, 'name'
         17        IS_IDENTICAL                                     ~19     ~18, 'bash'
         18        BOOL                                             ~17     ~19
         19    > > JMPZ                                                     ~17, ->23
  436    20    >   FETCH_DIM_R                                      ~20     !6, 'experience'
         21        ASSIGN_OP                                     1          !3, ~20
  437    22        PRE_INC                                                  !4
  431    23    > > JMP                                                      ->13
         24    >   FE_FREE                                                  $16
  429    25    > > JMP                                                      ->7
         26    >   FE_FREE                                                  $12
  442    27      > JMPZ                                                     !4, ->31
         28    >   DIV                                              ~24     !3, !4
         29        QM_ASSIGN                                        ~25     ~24
         30      > JMP                                                      ->32
         31    >   QM_ASSIGN                                        ~25     0
         32    >   ASSIGN_DIM                                               !1
         33        OP_DATA                                                  ~25
  427    34        PRE_INC                                                  !2
         35    >   IS_SMALLER                                               !2, 10000
         36      > JMPNZ                                                    ~27, ->4
  444    37    >   COUNT                                            ~28     !1
         38        ECHO                                                     ~28
         39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.83 ms | 1399 KiB | 13 Q