3v4l.org

run code in 300+ 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 = 39
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 36
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 36
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 = 35
Branch analysis from position: 35
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: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
Branch analysis from position: 39
Branch analysis from position: 7
filename:       /in/kOi2N
function name:  custom_function
number of ops:  44
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, ->39
   83     8    >   ASSIGN_DIM                                               !1
          9        OP_DATA                                                  '%3Cul%3E'
   84    10      > FE_RESET_R                                       $8      !0, ->36
         11    > > FE_FETCH_R                                               $8, !2, ->36
   85    12    >   ISSET_ISEMPTY_DIM_OBJ                         0          !2, 'children'
         13      > JMPZ                                                     ~9, ->28
   86    14    >   INIT_FCALL                                               'sprintf'
         15        SEND_VAL                                                 '%3Cli%3E%25s+%25s%3C%2Fli%3E'
         16        FETCH_DIM_R                                      ~11     !2, 'cat_name'
         17        SEND_VAL                                                 ~11
         18        INIT_FCALL_BY_NAME                                       'custom_function'
         19        CHECK_FUNC_ARG                                           
         20        FETCH_DIM_FUNC_ARG                               $12     !2, 'children'
         21        SEND_FUNC_ARG                                            $12
         22        DO_FCALL                                      0  $13     
         23        SEND_VAR                                                 $13
         24        DO_ICALL                                         $14     
         25        ASSIGN_DIM                                               !1
         26        OP_DATA                                                  $14
   85    27      > JMP                                                      ->35
   88    28    >   INIT_FCALL                                               'sprintf'
         29        SEND_VAL                                                 '%3Cli%3E%25s%3C%2Fli%3E'
         30        FETCH_DIM_R                                      ~16     !2, 'cat_name'
         31        SEND_VAL                                                 ~16
         32        DO_ICALL                                         $17     
         33        ASSIGN_DIM                                               !1
         34        OP_DATA                                                  $17
   84    35    > > JMP                                                      ->11
         36    >   FE_FREE                                                  $8
   91    37        ASSIGN_DIM                                               !1
         38        OP_DATA                                                  '%3C%2Ful%3E'
   93    39    >   INIT_FCALL                                               'implode'
         40        SEND_VAR                                                 !1
         41        DO_ICALL                                         $19     
         42      > RETURN                                                   $19
   94    43*     > RETURN                                                   null

End of function custom_function

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.63 ms | 1010 KiB | 16 Q