3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_some(callable $callback,$arr){ foreach($arr as $ele){ if(call_user_func($callback,$ele)){ return true; } } return false; } function array_every(callable $callback,$arr){ foreach($arr as $ele){ if(!call_user_func($callback,$ele)){ return false; } } return true; } function my_callback($ele){ return $ele % 2 == 0; } var_dump(array_some('my_callback',[1,2,3,4,5,6,7,8,9,10])); var_dump(array_some('my_callback',[1,3,5,7])); var_dump(array_every('my_callback',[1,2,3,4,5,6,7,8,9,10])); var_dump(array_every('my_callback',[0,2,4,6,8]));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1DUDu
function name:  (null)
number of ops:  29
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'array_some'
          2        SEND_VAL                                                 'my_callback'
          3        SEND_VAL                                                 <array>
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   28     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'array_some'
          9        SEND_VAL                                                 'my_callback'
         10        SEND_VAL                                                 <array>
         11        DO_FCALL                                      0  $2      
         12        SEND_VAR                                                 $2
         13        DO_ICALL                                                 
   29    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL                                               'array_every'
         16        SEND_VAL                                                 'my_callback'
         17        SEND_VAL                                                 <array>
         18        DO_FCALL                                      0  $4      
         19        SEND_VAR                                                 $4
         20        DO_ICALL                                                 
   30    21        INIT_FCALL                                               'var_dump'
         22        INIT_FCALL                                               'array_every'
         23        SEND_VAL                                                 'my_callback'
         24        SEND_VAL                                                 <array>
         25        DO_FCALL                                      0  $6      
         26        SEND_VAR                                                 $6
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Function array_some:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/1DUDu
function name:  array_some
number of ops:  14
compiled vars:  !0 = $callback, !1 = $arr, !2 = $ele
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2      > FE_RESET_R                                       $3      !1, ->11
          3    > > FE_FETCH_R                                               $3, !2, ->11
    6     4    >   INIT_USER_CALL                                1          'call_user_func', !0
          5        SEND_USER                                                !2
          6        DO_FCALL                                      0  $4      
          7      > JMPZ                                                     $4, ->10
    7     8    >   FE_FREE                                                  $3
          9      > RETURN                                                   <true>
    5    10    > > JMP                                                      ->3
         11    >   FE_FREE                                                  $3
   10    12      > RETURN                                                   <false>
   11    13*     > RETURN                                                   null

End of function array_some

Function array_every:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
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 = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/1DUDu
function name:  array_every
number of ops:  15
compiled vars:  !0 = $callback, !1 = $arr, !2 = $ele
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2      > FE_RESET_R                                       $3      !1, ->12
          3    > > FE_FETCH_R                                               $3, !2, ->12
   16     4    >   INIT_USER_CALL                                1          'call_user_func', !0
          5        SEND_USER                                                !2
          6        DO_FCALL                                      0  $4      
          7        BOOL_NOT                                         ~5      $4
          8      > JMPZ                                                     ~5, ->11
   17     9    >   FE_FREE                                                  $3
         10      > RETURN                                                   <false>
   15    11    > > JMP                                                      ->3
         12    >   FE_FREE                                                  $3
   20    13      > RETURN                                                   <true>
   21    14*     > RETURN                                                   null

End of function array_every

Function my_callback:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1DUDu
function name:  my_callback
number of ops:  5
compiled vars:  !0 = $ele
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   24     1        MOD                                              ~1      !0, 2
          2        IS_EQUAL                                         ~2      ~1, 0
          3      > RETURN                                                   ~2
   25     4*     > RETURN                                                   null

End of function my_callback

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.01 ms | 1005 KiB | 18 Q