3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ids = [1,2,3,4,5,6,7,8,9,10]; function createMultipleFromArticles($productsId): array { $randomIds = [1,4,6,7,9,10,2,3,5,8]; // It can be possible to have multiple product in the same page $productsId = array_unique($productsId); $positions = array_flip($productsId); $products = $randomIds; $products = array_combine($productsId, $products); var_export($products); return array_map(function (int $productId) use ($products, $positions) { return [$products[$productId], $positions[$productId] + 1]; // return $this->create($products[$productId], $positions[$productId] + 1); }, $productsId); } var_export(createMultipleFromArticles($ids));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N8d5g
function name:  (null)
number of ops:  8
compiled vars:  !0 = $ids
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   22     1        INIT_FCALL                                               'var_export'
          2        INIT_FCALL                                               'createmultiplefromarticles'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function createmultiplefromarticles:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N8d5g
function name:  createMultipleFromArticles
number of ops:  30
compiled vars:  !0 = $productsId, !1 = $randomIds, !2 = $positions, !3 = $products
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ASSIGN                                                   !1, <array>
   10     2        INIT_FCALL                                               'array_unique'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !0, $5
   11     6        INIT_FCALL                                               'array_flip'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !2, $7
   12    10        ASSIGN                                                   !3, !1
   13    11        INIT_FCALL                                               'array_combine'
         12        SEND_VAR                                                 !0
         13        SEND_VAR                                                 !3
         14        DO_ICALL                                         $10     
         15        ASSIGN                                                   !3, $10
   14    16        INIT_FCALL                                               'var_export'
         17        SEND_VAR                                                 !3
         18        DO_ICALL                                                 
   16    19        INIT_FCALL                                               'array_map'
         20        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FN8d5g%3A16%240'
         21        BIND_LEXICAL                                             ~13, !3
         22        BIND_LEXICAL                                             ~13, !2
   19    23        SEND_VAL                                                 ~13
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                         $14     
         26        VERIFY_RETURN_TYPE                                       $14
         27      > RETURN                                                   $14
   20    28*       VERIFY_RETURN_TYPE                                       
         29*     > RETURN                                                   null

End of function createmultiplefromarticles

Function %00%7Bclosure%7D%2Fin%2FN8d5g%3A16%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N8d5g
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $productId, !1 = $products, !2 = $positions
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   17     3        FETCH_DIM_R                                      ~3      !1, !0
          4        INIT_ARRAY                                       ~4      ~3
          5        FETCH_DIM_R                                      ~5      !2, !0
          6        ADD                                              ~6      ~5, 1
          7        ADD_ARRAY_ELEMENT                                ~4      ~6
          8      > RETURN                                                   ~4
   19     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FN8d5g%3A16%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.62 ms | 1407 KiB | 24 Q