3v4l.org

run code in 300+ PHP versions simultaneously
<?php $weight = array('Galeria', 'Rss', 'Grande', 'Mediana'); $options = array(1, 2); // de las opciones disponibles obtener la de mayor peso $option = 3; array_reduce($options, function(&$option, $item) use ($weight) { echo $option; echo $item; return ($option > $item) ? $option : $item; }); var_dump($option); die; $tamano = 'Rss'; echo $attachmentSizes[$tamano]; die; $fotos = array(array('idAdjunto' => 1, 'tamano' => 'Grande'), array('idAdjunto' => 2, 'tamano'=>'Galeria'), array('idAdjunto' => 3, 'tamano'=>'Mediana')); $foto = array_filter($fotos, function($foto) use ($attachmentSizes) { return in_array($foto['tamano'], $attachmentSizes); }); $foto = array_shift($foto); var_dump($foto);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/vnb9A
function name:  (null)
number of ops:  33
compiled vars:  !0 = $weight, !1 = $options, !2 = $option, !3 = $tamano, !4 = $attachmentSizes, !5 = $fotos, !6 = $foto
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    7     2        ASSIGN                                                   !2, 3
    8     3        INIT_FCALL                                               'array_reduce'
          4        SEND_VAR                                                 !1
          5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fvnb9A%3A8%240'
          6        BIND_LEXICAL                                             ~10, !0
   12     7        SEND_VAL                                                 ~10
          8        DO_ICALL                                                 
   14     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
   15    12      > EXIT                                                     
   19    13*       ASSIGN                                                   !3, 'Rss'
   20    14*       FETCH_DIM_R                                      ~14     !4, !3
         15*       ECHO                                                     ~14
   21    16*       EXIT                                                     
   23    17*       ASSIGN                                                   !5, <array>
   25    18*       INIT_FCALL                                               'array_filter'
         19*       SEND_VAR                                                 !5
         20*       DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fvnb9A%3A25%241'
         21*       BIND_LEXICAL                                             ~16, !4
   27    22*       SEND_VAL                                                 ~16
         23*       DO_ICALL                                         $17     
   25    24*       ASSIGN                                                   !6, $17
   28    25*       INIT_FCALL                                               'array_shift'
         26*       SEND_REF                                                 !6
         27*       DO_ICALL                                         $19     
         28*       ASSIGN                                                   !6, $19
   30    29*       INIT_FCALL                                               'var_dump'
         30*       SEND_VAR                                                 !6
         31*       DO_ICALL                                                 
         32*     > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fvnb9A%3A8%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vnb9A
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $option, !1 = $item, !2 = $weight
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
    9     3        ECHO                                                     !0
   10     4        ECHO                                                     !1
   11     5        IS_SMALLER                                               !1, !0
          6      > JMPZ                                                     ~3, ->9
          7    >   QM_ASSIGN                                        ~4      !0
          8      > JMP                                                      ->10
          9    >   QM_ASSIGN                                        ~4      !1
         10    > > RETURN                                                   ~4
   12    11*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fvnb9A%3A8%240

Function %00%7Bclosure%7D%2Fin%2Fvnb9A%3A25%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vnb9A
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $foto, !1 = $attachmentSizes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   26     2        INIT_FCALL                                               'in_array'
          3        FETCH_DIM_R                                      ~2      !0, 'tamano'
          4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $3      
          7      > RETURN                                                   $3
   27     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fvnb9A%3A25%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.53 ms | 1400 KiB | 23 Q