3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(get_catering_posts()); function get_catering_posts() { // For each category in the Catering category, fetch their posts return array_map(function ($category) { $category->posts = array_map(function (&$post) use ($category) { // Filter only the custom fields we need to render the page $post->custom_fields = array_filter(get_post_custom($post->ID), function ($item, $item_key) { return in_array($item_key, array( 'price', 'price_portion', 'serving', 'minimum_order', )); }, ARRAY_FILTER_USE_BOTH); return $post; }, get_posts(array( 'category' => $category->cat_ID, ))); return $category; }, get_categories(array( 'child_of' => 16, ))); } function get_posts($array) { return array( 0 => new stdClass, 1 => new stdClass, ); } function get_categories($array) { return array( 0 => new stdClass, 1 => new stdClass, ); } function get_post_custom($id) { return array( 'price' => 'price', 'price_portion' => 'price_portion', 'serving' => 'serving', 'minimum_order' => 'minimum_order', ); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jp5f5
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL_BY_NAME                                       'get_catering_posts'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                                 
   32     5      > RETURN                                                   1

Function get_catering_posts:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jp5f5
function name:  get_catering_posts
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'array_map'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fjp5f5%3A7%240'
   18     2        SEND_VAL                                                 ~0
          3        INIT_FCALL_BY_NAME                                       'get_categories'
          4        SEND_VAL_EX                                              <array>
          5        DO_FCALL                                      0  $1      
          6        SEND_VAR                                                 $1
          7        DO_ICALL                                         $2      
          8      > RETURN                                                   $2
   19     9*     > RETURN                                                   null

End of function get_catering_posts

Function %00%7Bclosure%7D%2Fin%2Fjp5f5%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jp5f5
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $category
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        INIT_FCALL                                               'array_map'
          2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fjp5f5%3A8%241'
          3        BIND_LEXICAL                                             ~2, !0
   15     4        SEND_VAL                                                 ~2
          5        INIT_FCALL_BY_NAME                                       'get_posts'
          6        FETCH_OBJ_R                                      ~3      !0, 'cat_ID'
          7        INIT_ARRAY                                       ~4      ~3, 'category'
          8        SEND_VAL_EX                                              ~4
          9        DO_FCALL                                      0  $5      
         10        SEND_VAR                                                 $5
         11        DO_ICALL                                         $6      
    8    12        ASSIGN_OBJ                                               !0, 'posts'
   15    13        OP_DATA                                                  $6
   17    14      > RETURN                                                   !0
   18    15*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fjp5f5%3A7%240

Function %00%7Bclosure%7D%2Fin%2Fjp5f5%3A8%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jp5f5
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $post, !1 = $category
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   10     2        INIT_FCALL                                               'array_filter'
          3        INIT_FCALL_BY_NAME                                       'get_post_custom'
          4        CHECK_FUNC_ARG                                           
          5        FETCH_OBJ_FUNC_ARG                               $3      !0, 'ID'
          6        SEND_FUNC_ARG                                            $3
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fjp5f5%3A10%242'
   12    10        SEND_VAL                                                 ~5
         11        SEND_VAL                                                 1
         12        DO_ICALL                                         $6      
   10    13        ASSIGN_OBJ                                               !0, 'custom_fields'
   12    14        OP_DATA                                                  $6
   14    15      > RETURN                                                   !0
   15    16*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fjp5f5%3A8%241

Function %00%7Bclosure%7D%2Fin%2Fjp5f5%3A10%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jp5f5
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $item, !1 = $item_key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        IN_ARRAY                                         ~2      !1, <array>
          3      > RETURN                                                   ~2
   12     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fjp5f5%3A10%242

Function get_posts:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jp5f5
function name:  get_posts
number of ops:  9
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        NEW                                              $1      'stdClass'
          2        DO_FCALL                                      0          
          3        INIT_ARRAY                                       ~3      $1, 0
          4        NEW                                              $4      'stdClass'
          5        DO_FCALL                                      0          
          6        ADD_ARRAY_ELEMENT                                ~3      $4, 1
          7      > RETURN                                                   ~3
   24     8*     > RETURN                                                   null

End of function get_posts

Function get_categories:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jp5f5
function name:  get_categories
number of ops:  9
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        NEW                                              $1      'stdClass'
          2        DO_FCALL                                      0          
          3        INIT_ARRAY                                       ~3      $1, 0
          4        NEW                                              $4      'stdClass'
          5        DO_FCALL                                      0          
          6        ADD_ARRAY_ELEMENT                                ~3      $4, 1
          7      > RETURN                                                   ~3
   28     8*     > RETURN                                                   null

End of function get_categories

Function get_post_custom:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jp5f5
function name:  get_post_custom
number of ops:  3
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1      > RETURN                                                   <array>
   32     2*     > RETURN                                                   null

End of function get_post_custom

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
233.77 ms | 1404 KiB | 19 Q