3v4l.org

run code in 300+ PHP versions simultaneously
<?php $weight = array('Galeria', 'Rss', 'Grande', 'Mediana'); $weight = array(1, 3, 5); $options = array(1, 2, 4, 2, 3, 5, 55, 2); // de las opciones disponibles obtener la de mayor peso $option = array_reduce($options, function(&$option, $item) use ($weight) { echo $item . PHP_EOL; if (in_array($item, $weight)) { 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/il4Ug
function name:  (null)
number of ops:  34
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                                                   !0, <array>
    5     2        ASSIGN                                                   !1, <array>
    9     3        INIT_FCALL                                               'array_reduce'
          4        SEND_VAR                                                 !1
          5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fil4Ug%3A9%240'
          6        BIND_LEXICAL                                             ~10, !0
   14     7        SEND_VAL                                                 ~10
          8        DO_ICALL                                         $11     
    9     9        ASSIGN                                                   !2, $11
   16    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                                 
   17    13      > EXIT                                                     
   21    14*       ASSIGN                                                   !3, 'Rss'
   22    15*       FETCH_DIM_R                                      ~15     !4, !3
         16*       ECHO                                                     ~15
   23    17*       EXIT                                                     
   25    18*       ASSIGN                                                   !5, <array>
   27    19*       INIT_FCALL                                               'array_filter'
         20*       SEND_VAR                                                 !5
         21*       DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fil4Ug%3A27%241'
         22*       BIND_LEXICAL                                             ~17, !4
   29    23*       SEND_VAL                                                 ~17
         24*       DO_ICALL                                         $18     
   27    25*       ASSIGN                                                   !6, $18
   30    26*       INIT_FCALL                                               'array_shift'
         27*       SEND_REF                                                 !6
         28*       DO_ICALL                                         $20     
         29*       ASSIGN                                                   !6, $20
   32    30*       INIT_FCALL                                               'var_dump'
         31*       SEND_VAR                                                 !6
         32*       DO_ICALL                                                 
         33*     > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2Fil4Ug%3A9%240

Function %00%7Bclosure%7D%2Fin%2Fil4Ug%3A27%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/il4Ug
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $foto, !1 = $attachmentSizes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   28     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
   29     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fil4Ug%3A27%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.8 ms | 1400 KiB | 23 Q