3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'code' => '001', 'name' => 'Prostite', 'whpr' => [ 'wh_price_rest' => [ ['price' => 255, 'wrh' => 1], ['price'=> 900, 'wrh' => 5] ] ] ], [ 'code' => '002', 'name' => 'Menya', 'whpr' => [ 'wh_price_rest' => [ ['price' => 34535, 'wrh' => 42], ['price'=> 5445, 'wrh' => 2432] ] ] ], ]; $result = []; foreach ($array as $item) { foreach ($item['whpr']['wh_price_rest'] as $key => $value) { unset($item['whpr']); foreach ($value as $k => $v) $item[$k] = $v; $result[] = $item; } } print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 22
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 20
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 16
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/2GXOI
function name:  (null)
number of ops:  27
compiled vars:  !0 = $array, !1 = $result, !2 = $item, !3 = $value, !4 = $key, !5 = $v, !6 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   26     1        ASSIGN                                                   !1, <array>
   28     2      > FE_RESET_R                                       $9      !0, ->22
          3    > > FE_FETCH_R                                               $9, !2, ->22
   29     4    >   FETCH_DIM_R                                      ~10     !2, 'whpr'
          5        FETCH_DIM_R                                      ~11     ~10, 'wh_price_rest'
          6      > FE_RESET_R                                       $12     ~11, ->20
          7    > > FE_FETCH_R                                       ~13     $12, !3, ->20
          8    >   ASSIGN                                                   !4, ~13
   30     9        UNSET_DIM                                                !2, 'whpr'
   31    10      > FE_RESET_R                                       $15     !3, ->16
         11    > > FE_FETCH_R                                       ~16     $15, !5, ->16
         12    >   ASSIGN                                                   !6, ~16
         13        ASSIGN_DIM                                               !2, !6
         14        OP_DATA                                                  !5
         15      > JMP                                                      ->11
         16    >   FE_FREE                                                  $15
   32    17        ASSIGN_DIM                                               !1
         18        OP_DATA                                                  !2
   29    19      > JMP                                                      ->7
         20    >   FE_FREE                                                  $12
   28    21      > JMP                                                      ->3
         22    >   FE_FREE                                                  $9
   36    23        INIT_FCALL                                               'print_r'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.78 ms | 1396 KiB | 15 Q