3v4l.org

run code in 300+ PHP versions simultaneously
<?php $reduce_unwanted_colors = function (&$arr) use (&$reduce_unwanted_colors) { $rand_key = array_rand($arr); if ($arr[$rand_key] == 'blue') { return $arr; } else { unset($arr[$rand_key]); return $reduce_unwanted_colors($arr); } }; $arr = ['red', 'green', 'blue', 'orange', 'yellow']; print_r($reduce_unwanted_colors($arr));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JknqN
function name:  (null)
number of ops:  11
compiled vars:  !0 = $reduce_unwanted_colors, !1 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          1        BIND_LEXICAL                                             ~2, !0
          2        ASSIGN                                                   !0, ~2
   17     3        ASSIGN                                                   !1, <array>
   18     4        INIT_FCALL                                               'print_r'
          5        INIT_DYNAMIC_CALL                                        !0
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $5      
          8        SEND_VAR                                                 $5
          9        DO_ICALL                                                 
         10      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JknqN
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $arr, !1 = $reduce_unwanted_colors, !2 = $rand_key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    5     2        INIT_FCALL                                               'array_rand'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !2, $3
    6     6        FETCH_DIM_R                                      ~5      !0, !2
          7        IS_EQUAL                                                 ~5, 'blue'
          8      > JMPZ                                                     ~6, ->11
    8     9    > > RETURN                                                   !0
    6    10*       JMP                                                      ->16
   12    11    >   UNSET_DIM                                                !0, !2
   13    12        INIT_DYNAMIC_CALL                                        !1
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0  $7      
         15      > RETURN                                                   $7
   15    16*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.73 ms | 1012 KiB | 15 Q