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 { // It can be possible to have multiple product in the same page $productsId = array_unique($productsId); $positions = array_flip($productsId); $products = [1,4,6,7,9,10,2,3,5,8]; $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/QgmVM
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>
   20     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/QgmVM
function name:  createMultipleFromArticles
number of ops:  29
compiled vars:  !0 = $productsId, !1 = $positions, !2 = $products
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    8     1        INIT_FCALL                                               'array_unique'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !0, $3
    9     5        INIT_FCALL                                               'array_flip'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !1, $5
   10     9        ASSIGN                                                   !2, <array>
   11    10        INIT_FCALL                                               'array_combine'
         11        SEND_VAR                                                 !0
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $8      
         14        ASSIGN                                                   !2, $8
   12    15        INIT_FCALL                                               'var_export'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                                 
   14    18        INIT_FCALL                                               'array_map'
         19        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FQgmVM%3A14%240'
         20        BIND_LEXICAL                                             ~11, !2
         21        BIND_LEXICAL                                             ~11, !1
   17    22        SEND_VAL                                                 ~11
         23        SEND_VAR                                                 !0
         24        DO_ICALL                                         $12     
         25        VERIFY_RETURN_TYPE                                       $12
         26      > RETURN                                                   $12
   18    27*       VERIFY_RETURN_TYPE                                       
         28*     > RETURN                                                   null

End of function createmultiplefromarticles

Function %00%7Bclosure%7D%2Fin%2FQgmVM%3A14%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QgmVM
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $productId, !1 = $products, !2 = $positions
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   15     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
   17     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FQgmVM%3A14%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.71 ms | 1394 KiB | 24 Q