3v4l.org

run code in 500+ PHP versions simultaneously
<?php $categories = [ 1 => 'cat1', 3 => 'cat3', 4 => 'cat4', 5 => 'cat5', 8 => 'cat8', 20 => 'cat20', 21 => 'cat21' ]; $results = [ 0 => [ 'title' => 'Some title', 'category_ids' => [1,3,5,20] ], 1 => [ 'title' => 'Example title 2', 'category_ids' => [4,8,21] ], 3 => [ 'title' => 'Example title 3', 'category_ids' => [1,3,5,20] ], ]; foreach($results as &$val){ $val['category_names'] = array_map(function($v) use ($categories){ return $categories[$v]; }, $val['category_ids']); } echo '<pre>'; print_r($results); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 126) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/YtqRE
function name:  (null)
number of ops:  20
compiled vars:  !0 = $categories, !1 = $results, !2 = $val
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   11     1        ASSIGN                                                       !1, <array>
   28     2      > FE_RESET_RW                                          $5      !1, ->14
          3    > > FE_FETCH_RW                                                  $5, !2, ->14
   29     4    >   INIT_FCALL                                                   'array_map'
          5        DECLARE_LAMBDA_FUNCTION                              ~7      [0]
          6        BIND_LEXICAL                                                 ~7, !0
   31     7        SEND_VAL                                                     ~7
          8        FETCH_DIM_R                                          ~8      !2, 'category_ids'
          9        SEND_VAL                                                     ~8
   29    10        DO_ICALL                                             $9      
         11        ASSIGN_DIM                                                   !2, 'category_names'
   31    12        OP_DATA                                                      $9
   28    13      > JMP                                                          ->3
         14    >   FE_FREE                                                      $5
   33    15        ECHO                                                         '%3Cpre%3E'
   34    16        INIT_FCALL                                                   'print_r'
         17        SEND_VAR                                                     !1
         18        DO_ICALL                                                     
   35    19      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YtqRE
function name:  {closure:/in/YtqRE:29}
number of ops:  5
compiled vars:  !0 = $v, !1 = $categories
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   29     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
   30     2        FETCH_DIM_R                                          ~2      !1, !0
          3      > RETURN                                                       ~2
   31     4*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
173.56 ms | 2302 KiB | 15 Q