3v4l.org

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

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

End of function %00%7Bclosure%7D%2Fin%2Fn40su%3A7%240

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

End of function %00%7Bclosure%7D%2Fin%2Fn40su%3A22%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.96 ms | 1400 KiB | 23 Q