3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = array ( 'main' => array ( 0 => array ( 'id' => 1, 'name_one' => 'banana', 'name_two' => '' ), 1 => array ( 'id' => 2, 'name_one' => 'orange', 'name_two' => 'banana' ), 2 => array ( 'id' => 3, 'name_one' => '', 'name_two' => 'orange' ), 3 => array ( 'id' => 4, 'name_one' => 'pear', 'name_two' => '' ), 4 => array ( 'id' => 5, 'name_one' => 'pear', 'name_two' => 'mango' ), 5 => array ( 'id' => 6, 'name_one' => '', 'name_two' => '' ) ) ); $counts = array(); foreach ($array['main'] as $item) { if (!empty($item['name_two'])) { @$counts[$item['name_two']]++; } elseif (!empty($item['name_one'])) { @$counts[$item['name_one']]++; } } foreach ($counts as $key => $count) { echo "$key: $count\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 23
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 22
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 22
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 33
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 33
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
Branch analysis from position: 23
filename:       /in/d6tKr
function name:  (null)
number of ops:  35
compiled vars:  !0 = $array, !1 = $counts, !2 = $item, !3 = $count, !4 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   44     1        ASSIGN                                                       !1, <array>
   45     2        FETCH_DIM_R                                          ~7      !0, 'main'
          3      > FE_RESET_R                                           $8      ~7, ->23
          4    > > FE_FETCH_R                                                   $8, !2, ->23
   46     5    >   ISSET_ISEMPTY_DIM_OBJ                             1  ~9      !2, 'name_two'
          6        BOOL_NOT                                             ~10     ~9
          7      > JMPZ                                                         ~10, ->14
   47     8    >   BEGIN_SILENCE                                        ~11     
          9        FETCH_DIM_R                                          ~12     !2, 'name_two'
         10        FETCH_DIM_RW                                         $13     !1, ~12
         11        PRE_INC                                                      $13
         12        END_SILENCE                                                  ~11
   46    13      > JMP                                                          ->22
   49    14    >   ISSET_ISEMPTY_DIM_OBJ                             1  ~15     !2, 'name_one'
         15        BOOL_NOT                                             ~16     ~15
         16      > JMPZ                                                         ~16, ->22
   50    17    >   BEGIN_SILENCE                                        ~17     
         18        FETCH_DIM_R                                          ~18     !2, 'name_one'
         19        FETCH_DIM_RW                                         $19     !1, ~18
         20        PRE_INC                                                      $19
         21        END_SILENCE                                                  ~17
   45    22    > > JMP                                                          ->4
         23    >   FE_FREE                                                      $8
   53    24      > FE_RESET_R                                           $21     !1, ->33
         25    > > FE_FETCH_R                                           ~22     $21, !3, ->33
         26    >   ASSIGN                                                       !4, ~22
   54    27        ROPE_INIT                                         4  ~25     !4
         28        ROPE_ADD                                          1  ~25     ~25, '%3A+'
         29        ROPE_ADD                                          2  ~25     ~25, !3
         30        ROPE_END                                          3  ~24     ~25, '%0A'
         31        ECHO                                                         ~24
   53    32      > JMP                                                          ->25
         33    >   FE_FREE                                                      $21
   55    34      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.66 ms | 2235 KiB | 13 Q