3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 0 => (object) ["class" => 1], 1 => (object) ["class" => 10], ]; $arr1 = [ 0 => (object) ["fee_amount" => 8285], 1 => (object) ["fee_amount" => 300], ]; function multiArrayCombine($array1, $array2) { $temp = array_map(null, $array1, $array2); // switch index wise data on either side foreach ($temp as $key => &$value) { // & to make changes at address of variable $value = json_decode(json_encode($value), true); // convert object to array $value = array_merge(...$value); // removing initial index and merge internally } return json_decode(json_encode($temp)); // convert back to object form } $arr = multiArrayCombine($arr, $arr1); // $arr = array_map(null,...$arr); print_r($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TmdZA
function name:  (null)
number of ops:  19
compiled vars:  !0 = $arr, !1 = $arr1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   CAST                                          8  ~2      <array>
          1        INIT_ARRAY                                       ~3      ~2, 0
    4     2        CAST                                          8  ~4      <array>
          3        ADD_ARRAY_ELEMENT                                ~3      ~4, 1
    2     4        ASSIGN                                                   !0, ~3
    7     5        CAST                                          8  ~6      <array>
          6        INIT_ARRAY                                       ~7      ~6, 0
    8     7        CAST                                          8  ~8      <array>
          8        ADD_ARRAY_ELEMENT                                ~7      ~8, 1
    6     9        ASSIGN                                                   !1, ~7
   19    10        INIT_FCALL                                               'multiarraycombine'
         11        SEND_VAR                                                 !0
         12        SEND_VAR                                                 !1
         13        DO_FCALL                                      0  $10     
         14        ASSIGN                                                   !0, $10
   21    15        INIT_FCALL                                               'print_r'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Function multiarraycombine:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 9, Position 2 = 25
Branch analysis from position: 9
2 jumps found. (Code = 126) Position 1 = 10, Position 2 = 25
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/TmdZA
function name:  multiArrayCombine
number of ops:  34
compiled vars:  !0 = $array1, !1 = $array2, !2 = $temp, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        INIT_FCALL                                               'array_map'
          3        SEND_VAL                                                 null
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !2, $5
   13     8      > FE_RESET_RW                                      $7      !2, ->25
          9    > > FE_FETCH_RW                                      ~8      $7, !3, ->25
         10    >   ASSIGN                                                   !4, ~8
   14    11        INIT_FCALL                                               'json_decode'
         12        INIT_FCALL                                               'json_encode'
         13        SEND_VAR                                                 !3
         14        DO_ICALL                                         $10     
         15        SEND_VAR                                                 $10
         16        SEND_VAL                                                 <true>
         17        DO_ICALL                                         $11     
         18        ASSIGN                                                   !3, $11
   15    19        INIT_FCALL                                               'array_merge'
         20        SEND_UNPACK                                              !3
         21        CHECK_UNDEF_ARGS                                         
         22        DO_ICALL                                         $13     
         23        ASSIGN                                                   !3, $13
   13    24      > JMP                                                      ->9
         25    >   FE_FREE                                                  $7
   17    26        INIT_FCALL                                               'json_decode'
         27        INIT_FCALL                                               'json_encode'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                         $15     
         30        SEND_VAR                                                 $15
         31        DO_ICALL                                         $16     
         32      > RETURN                                                   $16
   18    33*     > RETURN                                                   null

End of function multiarraycombine

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.16 ms | 1009 KiB | 19 Q