3v4l.org

run code in 300+ PHP versions simultaneously
<?php $source=json_decode('[{"parentTitle":"Winner 2009","catTitle":"Mas Muster","title":"drm202","id":"5","alias":"item1","catalias":"first"},{"parentTitle":"Winner 2009","catTitle":"Mas Muster","title":"drm202","id":"2","alias":"item2","catalias":"first"},{"parentTitle":"Winner 2011","catTitle":"Josh Frank","title":"A bird in the cage","id":"6","alias":"item3","catalias":"second"},{"parentTitle":"Winner 2011","catTitle":"Josh Frank","title":"cue & repeat","id":"7","alias":"item4","catalias":"third"}]'); $result=array(); array_walk($source,function($v,$i)use(&$result){ if(!isset($result[$v->parentTitle])) $result[$v->parentTitle]=array(); if(!isset($result[$v->parentTitle][$v->catTitle])) $result[$v->parentTitle][$v->catTitle]=array(); if(!in_array($v->title,$result[$v->parentTitle][$v->catTitle])) $result[$v->parentTitle][$v->catTitle][]=$v->title; }); print_r($result); // just to debug echo "<ul>"; foreach($result as $key=>$sub){ echo "<li>".htmlentities($key,ENT_COMPAT,"UTF-8"); echo "\n<ul>"; foreach($sub as $k=>$s){ echo "<li>".htmlentities($k,ENT_COMPAT,"UTF-8"); echo "\n<ul>"; foreach($s as $i=>$v){ echo "<li>".htmlentities($v,ENT_COMPAT,"UTF-8")."</li>\n"; } echo "</ul>\n</li>"; } echo "</ul>\n</li>"; } echo "</ul>";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 55
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 55
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 52
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 52
Branch analysis from position: 28
2 jumps found. (Code = 77) Position 1 = 38, Position 2 = 49
Branch analysis from position: 38
2 jumps found. (Code = 78) Position 1 = 39, Position 2 = 49
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 49
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 52
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
filename:       /in/qJZvp
function name:  (null)
number of ops:  58
compiled vars:  !0 = $source, !1 = $result, !2 = $sub, !3 = $key, !4 = $s, !5 = $k, !6 = $v, !7 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'json_decode'
          1        SEND_VAL                                                 '%5B%7B%22parentTitle%22%3A%22Winner+2009%22%2C%22catTitle%22%3A%22Mas+Muster%22%2C%22title%22%3A%22drm202%22%2C%22id%22%3A%225%22%2C%22alias%22%3A%22item1%22%2C%22catalias%22%3A%22first%22%7D%2C%7B%22parentTitle%22%3A%22Winner+2009%22%2C%22catTitle%22%3A%22Mas+Muster%22%2C%22title%22%3A%22drm202%22%2C%22id%22%3A%222%22%2C%22alias%22%3A%22item2%22%2C%22catalias%22%3A%22first%22%7D%2C%7B%22parentTitle%22%3A%22Winner+2011%22%2C%22catTitle%22%3A%22Josh+Frank%22%2C%22title%22%3A%22A+bird+in+the+cage%22%2C%22id%22%3A%226%22%2C%22alias%22%3A%22item3%22%2C%22catalias%22%3A%22second%22%7D%2C%7B%22parentTitle%22%3A%22Winner+2011%22%2C%22catTitle%22%3A%22Josh+Frank%22%2C%22title%22%3A%22cue+%26+repeat%22%2C%22id%22%3A%227%22%2C%22alias%22%3A%22item4%22%2C%22catalias%22%3A%22third%22%7D%5D'
          2        DO_ICALL                                         $8      
          3        ASSIGN                                                   !0, $8
    3     4        ASSIGN                                                   !1, <array>
    4     5        INIT_FCALL                                               'array_walk'
          6        SEND_REF                                                 !0
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FqJZvp%3A4%240'
          8        BIND_LEXICAL                                             ~11, !1
    8     9        SEND_VAL                                                 ~11
         10        DO_ICALL                                                 
    9    11        INIT_FCALL                                               'print_r'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
   10    14        ECHO                                                     '%3Cul%3E'
   11    15      > FE_RESET_R                                       $14     !1, ->55
         16    > > FE_FETCH_R                                       ~15     $14, !2, ->55
         17    >   ASSIGN                                                   !3, ~15
   12    18        INIT_FCALL                                               'htmlentities'
         19        SEND_VAR                                                 !3
         20        SEND_VAL                                                 2
         21        SEND_VAL                                                 'UTF-8'
         22        DO_ICALL                                         $17     
         23        CONCAT                                           ~18     '%3Cli%3E', $17
         24        ECHO                                                     ~18
   13    25        ECHO                                                     '%0A%3Cul%3E'
   14    26      > FE_RESET_R                                       $19     !2, ->52
         27    > > FE_FETCH_R                                       ~20     $19, !4, ->52
         28    >   ASSIGN                                                   !5, ~20
   15    29        INIT_FCALL                                               'htmlentities'
         30        SEND_VAR                                                 !5
         31        SEND_VAL                                                 2
         32        SEND_VAL                                                 'UTF-8'
         33        DO_ICALL                                         $22     
         34        CONCAT                                           ~23     '%3Cli%3E', $22
         35        ECHO                                                     ~23
   16    36        ECHO                                                     '%0A%3Cul%3E'
   17    37      > FE_RESET_R                                       $24     !4, ->49
         38    > > FE_FETCH_R                                       ~25     $24, !6, ->49
         39    >   ASSIGN                                                   !7, ~25
   18    40        INIT_FCALL                                               'htmlentities'
         41        SEND_VAR                                                 !6
         42        SEND_VAL                                                 2
         43        SEND_VAL                                                 'UTF-8'
         44        DO_ICALL                                         $27     
         45        CONCAT                                           ~28     '%3Cli%3E', $27
         46        CONCAT                                           ~29     ~28, '%3C%2Fli%3E%0A'
         47        ECHO                                                     ~29
   17    48      > JMP                                                      ->38
         49    >   FE_FREE                                                  $24
   20    50        ECHO                                                     '%3C%2Ful%3E%0A%3C%2Fli%3E'
   14    51      > JMP                                                      ->27
         52    >   FE_FREE                                                  $19
   22    53        ECHO                                                     '%3C%2Ful%3E%0A%3C%2Fli%3E'
   11    54      > JMP                                                      ->16
         55    >   FE_FREE                                                  $14
   24    56        ECHO                                                     '%3C%2Ful%3E'
         57      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FqJZvp%3A4%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 39
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
Branch analysis from position: 21
Branch analysis from position: 10
filename:       /in/qJZvp
function name:  {closure}
number of ops:  40
compiled vars:  !0 = $v, !1 = $i, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
    5     3        FETCH_OBJ_R                                      ~3      !0, 'parentTitle'
          4        ISSET_ISEMPTY_DIM_OBJ                         0  ~4      !2, ~3
          5        BOOL_NOT                                         ~5      ~4
          6      > JMPZ                                                     ~5, ->10
          7    >   FETCH_OBJ_R                                      ~6      !0, 'parentTitle'
          8        ASSIGN_DIM                                               !2, ~6
          9        OP_DATA                                                  <array>
    6    10    >   FETCH_OBJ_R                                      ~8      !0, 'parentTitle'
         11        FETCH_OBJ_R                                      ~10     !0, 'catTitle'
         12        FETCH_DIM_IS                                     ~9      !2, ~8
         13        ISSET_ISEMPTY_DIM_OBJ                         0  ~11     ~9, ~10
         14        BOOL_NOT                                         ~12     ~11
         15      > JMPZ                                                     ~12, ->21
         16    >   FETCH_OBJ_R                                      ~13     !0, 'parentTitle'
         17        FETCH_OBJ_R                                      ~15     !0, 'catTitle'
         18        FETCH_DIM_W                                      $14     !2, ~13
         19        ASSIGN_DIM                                               $14, ~15
         20        OP_DATA                                                  <array>
    7    21    >   INIT_FCALL                                               'in_array'
         22        FETCH_OBJ_R                                      ~17     !0, 'title'
         23        SEND_VAL                                                 ~17
         24        FETCH_OBJ_R                                      ~18     !0, 'parentTitle'
         25        FETCH_OBJ_R                                      ~20     !0, 'catTitle'
         26        FETCH_DIM_R                                      ~19     !2, ~18
         27        FETCH_DIM_R                                      ~21     ~19, ~20
         28        SEND_VAL                                                 ~21
         29        DO_ICALL                                         $22     
         30        BOOL_NOT                                         ~23     $22
         31      > JMPZ                                                     ~23, ->39
         32    >   FETCH_OBJ_R                                      ~24     !0, 'parentTitle'
         33        FETCH_OBJ_R                                      ~26     !0, 'catTitle'
         34        FETCH_OBJ_R                                      ~29     !0, 'title'
         35        FETCH_DIM_W                                      $25     !2, ~24
         36        FETCH_DIM_W                                      $27     $25, ~26
         37        ASSIGN_DIM                                               $27
         38        OP_DATA                                                  ~29
    8    39    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FqJZvp%3A4%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.24 ms | 1404 KiB | 23 Q