3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [ 0 => [ "id" => "1", "parent_cat_name" => "0", "cat_name" => "Test 1", "status" => "1", "position" => "1", "created_at" => "2019-09-03 09:27:45", "updated_at" => "2019-09-03 11:00:54", "children" => [ 0 => [ "id" => "2", "parent_cat_name" => "1", "cat_name" => "Test 2", "status" => "1", "position" => "2", "created_at" => "2019-09-03 09:28:19", "updated_at" => "2019-09-03 11:01:00", "children" => [ 0 => [ "id" => "4", "parent_cat_name" => "2", "cat_name" => "Test 4", "status" => "1", "position" => "4", "created_at" => "2019-09-03 09:35:20", "updated_at" => "2019-09-03 11:01:03", "children" => [ 0 => [ "id" => "5", "parent_cat_name" => "4", "cat_name" => "Test 5", "status" => "1", "position" => "3", "created_at" => "2019-09-07 05:55:09", "updated_at" => "2019-09-07 05:55:09", ], ], ], ], ], ], ], 1 => [ "id" => "3", "parent_cat_name" => "0", "cat_name" => "Test 3", "status" => "1", "position" => "4", "created_at" => "2019-09-03 09:35:10", "updated_at" => "2019-09-03 11:00:58", ], ]; /** * @param $data */ /** * @param $data */ function custom_function($data) { $result = []; if (is_array($data) && count($data) > 0) { $result[] = '<ul>'; foreach ($data as $entry) { if (isset($entry['children'])) { $result[] = sprintf('<li>%s %s</li>', $entry['cat_name'], custom_function($entry['children'])); } else { $result[] = sprintf('<li>%s</li>', $entry['cat_name']); } } $result[] = '</ul>'; } return implode($result); } echo custom_function($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kOi2N
function name:  (null)
number of ops:  6
compiled vars:  !0 = $arr
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   95     1        INIT_FCALL                                                   'custom_function'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $2      
          4        ECHO                                                         $2
          5      > RETURN                                                       1

Function custom_function:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 38
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 35
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 35
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 28
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
Branch analysis from position: 38
Branch analysis from position: 7
filename:       /in/kOi2N
function name:  custom_function
number of ops:  41
compiled vars:  !0 = $data, !1 = $result, !2 = $entry
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   79     0  E >   RECV                                                 !0      
   81     1        ASSIGN                                                       !1, <array>
   82     2        TYPE_CHECK                                      128  ~4      !0
          3      > JMPZ_EX                                              ~4      ~4, ->7
          4    >   COUNT                                                ~5      !0
          5        IS_SMALLER                                           ~6      0, ~5
          6        BOOL                                                 ~4      ~6
          7    > > JMPZ                                                         ~4, ->38
   83     8    >   ASSIGN_DIM                                                   !1
          9        OP_DATA                                                      '%3Cul%3E'
   84    10      > FE_RESET_R                                           $8      !0, ->35
         11    > > FE_FETCH_R                                                   $8, !2, ->35
   85    12    >   ISSET_ISEMPTY_DIM_OBJ                             0          !2, 'children'
         13      > JMPZ                                                         ~9, ->28
   86    14    >   FETCH_DIM_R                                          ~11     !2, 'cat_name'
         15        INIT_FCALL_BY_NAME                                           'custom_function'
         16        CHECK_FUNC_ARG                                               
         17        FETCH_DIM_FUNC_ARG                                   $12     !2, 'children'
         18        SEND_FUNC_ARG                                                $12
         19        DO_FCALL                                          0  $13     
         20        ROPE_INIT                                         5  ~15     '%3Cli%3E'
         21        ROPE_ADD                                          1  ~15     ~15, ~11
         22        ROPE_ADD                                          2  ~15     ~15, '+'
         23        ROPE_ADD                                          3  ~15     ~15, $13
         24        ROPE_END                                          4  ~14     ~15, '%3C%2Fli%3E'
         25        ASSIGN_DIM                                                   !1
         26        OP_DATA                                                      ~14
   85    27      > JMP                                                          ->34
   88    28    >   FETCH_DIM_R                                          ~19     !2, 'cat_name'
         29        ROPE_INIT                                         3  ~21     '%3Cli%3E'
         30        ROPE_ADD                                          1  ~21     ~21, ~19
         31        ROPE_END                                          2  ~20     ~21, '%3C%2Fli%3E'
         32        ASSIGN_DIM                                                   !1
         33        OP_DATA                                                      ~20
   84    34    > > JMP                                                          ->11
         35    >   FE_FREE                                                      $8
   91    36        ASSIGN_DIM                                                   !1
         37        OP_DATA                                                      '%3C%2Ful%3E'
   93    38    >   FRAMELESS_ICALL_1                implode             ~24     !1
         39      > RETURN                                                       ~24
   94    40*     > RETURN                                                       null

End of function custom_function

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
156.89 ms | 2101 KiB | 14 Q