3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array ( '@attributes' => array ( 'Category' => 'primary', ), 'SwatchImage' => array ( 'URL' => 'https://images-na.ssl-images-amazon.com/images/I/41ElcqNVGmL._SL30_.jpg', 'Height' => '20', 'Width' => '30', ), 'SmallImage' => array ( 'URL' => 'https://images-na.ssl-images-amazon.com/images/I/41ElcqNVGmL._SL75_.jpg', 'Height' => '49', 'Width' => '75', ), 'ThumbnailImage' => array ( 'URL' => 'https://images-na.ssl-images-amazon.com/images/I/41ElcqNVGmL._SL75_.jpg', 'Height' => '49', 'Width' => '75', ), 'TinyImage' => array ( 'URL' => 'https://images-na.ssl-images-amazon.com/images/I/41ElcqNVGmL._SL110_.jpg', 'Height' => '72', 'Width' => '110', ), 'MediumImage' => array ( 'URL' => 'https://images-na.ssl-images-amazon.com/images/I/41ElcqNVGmL._SL160_.jpg', 'Height' => '104', 'Width' => '160', ), 'LargeImage' => array ( 'URL' => 'https://images-na.ssl-images-amazon.com/images/I/41ElcqNVGmL.jpg', 'Height' => '325', 'Width' => '500', ), 'HiResImage' => array ( 'URL' => 'https://images-na.ssl-images-amazon.com/images/I/81OwsmYhlcL.jpg', 'Height' => '1300', 'Width' => '2000', ), ); $sizesFor = [ 'primary' => [ 'SwatchImage', 'SmallImage', 'ThumbnailImage', 'TinyImage', 'MediumImage', 'LargeImage', 'HiResImage' ], 'variant' => [ 'MediumImage','LargeImage' ] ]; $productImages = []; foreach ($array as $key => $value) { if(isset($value['@attributes'])) { if(isset($sizesFor[$value['@attributes']['Category']])) { foreach ($sizesFor[$value['@attributes']['Category']] as $k => $type) { if (!isset($value[$type])) continue; $productImage->image_type = $value['@attributes']['Category']; $productImage->image_size = $type; $productImage->image_link = $value[$type]['URL']; $productImage->image_order = $k; $productImages[] = $productImage; } } } if($key === '@attributes') { foreach ($sizesFor['primary'] as $order => $type) { if (!isset($type)) continue; $productImage->image_type = $value; $productImage->image_size = $type; $productImage->image_link = $type['URL']; $productImage->image_order = $order; dd($productImage); $productImages[] = $productImage; } } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 65
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 65
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 38
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 38
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 37
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 37
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 64
Branch analysis from position: 40
2 jumps found. (Code = 77) Position 1 = 42, Position 2 = 63
Branch analysis from position: 42
2 jumps found. (Code = 78) Position 1 = 43, Position 2 = 63
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 48
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 63
Branch analysis from position: 64
Branch analysis from position: 37
Branch analysis from position: 38
Branch analysis from position: 38
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
filename:       /in/kd6Hk
function name:  (null)
number of ops:  67
compiled vars:  !0 = $array, !1 = $sizesFor, !2 = $productImages, !3 = $value, !4 = $key, !5 = $type, !6 = $k, !7 = $productImage, !8 = $order
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
   53     1        ASSIGN                                                   !1, <array>
   61     2        ASSIGN                                                   !2, <array>
   63     3      > FE_RESET_R                                       $12     !0, ->65
          4    > > FE_FETCH_R                                       ~13     $12, !3, ->65
          5    >   ASSIGN                                                   !4, ~13
   64     6        ISSET_ISEMPTY_DIM_OBJ                         0          !3, '%40attributes'
          7      > JMPZ                                                     ~15, ->38
   65     8    >   FETCH_DIM_R                                      ~16     !3, '%40attributes'
          9        FETCH_DIM_R                                      ~17     ~16, 'Category'
         10        ISSET_ISEMPTY_DIM_OBJ                         0          !1, ~17
         11      > JMPZ                                                     ~18, ->38
   66    12    >   FETCH_DIM_R                                      ~19     !3, '%40attributes'
         13        FETCH_DIM_R                                      ~20     ~19, 'Category'
         14        FETCH_DIM_R                                      ~21     !1, ~20
         15      > FE_RESET_R                                       $22     ~21, ->37
         16    > > FE_FETCH_R                                       ~23     $22, !5, ->37
         17    >   ASSIGN                                                   !6, ~23
   67    18        ISSET_ISEMPTY_DIM_OBJ                         0  ~25     !3, !5
         19        BOOL_NOT                                         ~26     ~25
         20      > JMPZ                                                     ~26, ->22
         21    > > JMP                                                      ->16
   68    22    >   FETCH_DIM_R                                      ~28     !3, '%40attributes'
         23        FETCH_DIM_R                                      ~29     ~28, 'Category'
         24        ASSIGN_OBJ                                               !7, 'image_type'
         25        OP_DATA                                                  ~29
   69    26        ASSIGN_OBJ                                               !7, 'image_size'
         27        OP_DATA                                                  !5
   70    28        FETCH_DIM_R                                      ~32     !3, !5
         29        FETCH_DIM_R                                      ~33     ~32, 'URL'
         30        ASSIGN_OBJ                                               !7, 'image_link'
         31        OP_DATA                                                  ~33
   71    32        ASSIGN_OBJ                                               !7, 'image_order'
         33        OP_DATA                                                  !6
   72    34        ASSIGN_DIM                                               !2
         35        OP_DATA                                                  !7
   66    36      > JMP                                                      ->16
         37    >   FE_FREE                                                  $22
   76    38    >   IS_IDENTICAL                                             !4, '%40attributes'
         39      > JMPZ                                                     ~36, ->64
   77    40    >   FETCH_DIM_R                                      ~37     !1, 'primary'
         41      > FE_RESET_R                                       $38     ~37, ->63
         42    > > FE_FETCH_R                                       ~39     $38, !5, ->63
         43    >   ASSIGN                                                   !8, ~39
   78    44        ISSET_ISEMPTY_CV                                 ~41     !5
         45        BOOL_NOT                                         ~42     ~41
         46      > JMPZ                                                     ~42, ->48
         47    > > JMP                                                      ->42
   79    48    >   ASSIGN_OBJ                                               !7, 'image_type'
         49        OP_DATA                                                  !3
   80    50        ASSIGN_OBJ                                               !7, 'image_size'
         51        OP_DATA                                                  !5
   81    52        FETCH_DIM_R                                      ~46     !5, 'URL'
         53        ASSIGN_OBJ                                               !7, 'image_link'
         54        OP_DATA                                                  ~46
   82    55        ASSIGN_OBJ                                               !7, 'image_order'
         56        OP_DATA                                                  !8
   83    57        INIT_FCALL_BY_NAME                                       'dd'
         58        SEND_VAR_EX                                              !7
         59        DO_FCALL                                      0          
   84    60        ASSIGN_DIM                                               !2
         61        OP_DATA                                                  !7
   77    62      > JMP                                                      ->42
         63    >   FE_FREE                                                  $38
   63    64    > > JMP                                                      ->4
         65    >   FE_FREE                                                  $12
   87    66      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.64 ms | 1399 KiB | 13 Q