3v4l.org

run code in 300+ PHP versions simultaneously
<?php function any(array $array, callable $predicate) { return ((bool) count($array)) && array_reduce($array, function ($bool, $item) use ($predicate) { return $bool || (bool) $predicate($item); }, false); } function all(array $array, callable $predicate) { return ((bool) count($array)) && array_reduce($array, function ($bool, $item) use ($predicate) { return $bool && (bool) $predicate($item); }, true); } $valuesArray = [ [ false, false, false ], [ false, false, true ], [ false, true, false ], [ false, true, true ], [ true, false, false ], [ true, false, true ], [ true, true, false ], [ true, true, true ], ]; foreach ($valuesArray as $values) { printf('Any for (%s) is %s' . PHP_EOL, implode(', ', array_map(function ($value) { return $value ? 'Yeop' : 'Nope'; }, $values)), any($values, function ($value) { return $value; }) ? 'Yeop' : 'Nope'); printf('All for (%s) is %s' . PHP_EOL, implode(', ', array_map(function ($value) { return $value ? 'Yeop' : 'Nope'; }, $values)), all($values, function ($value) { return $value; }) ? 'Yeop' : 'Nope'); echo PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 51
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 51
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
Branch analysis from position: 46
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
filename:       /in/MIs04
function name:  (null)
number of ops:  53
compiled vars:  !0 = $valuesArray, !1 = $values
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, <array>
   26     1      > FE_RESET_R                                       $3      !0, ->51
          2    > > FE_FETCH_R                                               $3, !1, ->51
   28     3    >   INIT_FCALL                                               'printf'
          4        SEND_VAL                                                 'Any+for+%28%25s%29+is+%25s%0A'
          5        INIT_FCALL                                               'implode'
          6        SEND_VAL                                                 '%2C+'
          7        INIT_FCALL                                               'array_map'
          8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMIs04%3A28%242'
   30     9        SEND_VAL                                                 ~4
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                         $6      
         14        SEND_VAR                                                 $6
         15        INIT_FCALL                                               'any'
         16        SEND_VAR                                                 !1
         17        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMIs04%3A30%243'
   32    18        SEND_VAL                                                 ~7
         19        DO_FCALL                                      0  $8      
         20      > JMPZ                                                     $8, ->23
         21    >   QM_ASSIGN                                        ~9      'Yeop'
         22      > JMP                                                      ->24
         23    >   QM_ASSIGN                                        ~9      'Nope'
         24    >   SEND_VAL                                                 ~9
         25        DO_ICALL                                                 
   34    26        INIT_FCALL                                               'printf'
         27        SEND_VAL                                                 'All+for+%28%25s%29+is+%25s%0A'
         28        INIT_FCALL                                               'implode'
         29        SEND_VAL                                                 '%2C+'
         30        INIT_FCALL                                               'array_map'
         31        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMIs04%3A34%244'
   36    32        SEND_VAL                                                 ~11
         33        SEND_VAR                                                 !1
         34        DO_ICALL                                         $12     
         35        SEND_VAR                                                 $12
         36        DO_ICALL                                         $13     
         37        SEND_VAR                                                 $13
         38        INIT_FCALL                                               'all'
         39        SEND_VAR                                                 !1
         40        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMIs04%3A36%245'
   38    41        SEND_VAL                                                 ~14
         42        DO_FCALL                                      0  $15     
         43      > JMPZ                                                     $15, ->46
         44    >   QM_ASSIGN                                        ~16     'Yeop'
         45      > JMP                                                      ->47
         46    >   QM_ASSIGN                                        ~16     'Nope'
         47    >   SEND_VAL                                                 ~16
         48        DO_ICALL                                                 
   40    49        ECHO                                                     '%0A'
   26    50      > JMP                                                      ->2
         51    >   FE_FREE                                                  $3
   42    52      > RETURN                                                   1

Function any:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/MIs04
function name:  any
number of ops:  15
compiled vars:  !0 = $array, !1 = $predicate
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        COUNT                                            ~2      !0
          3        BOOL                                             ~3      ~2
          4      > JMPZ_EX                                          ~3      ~3, ->13
          5    >   INIT_FCALL                                               'array_reduce'
          6        SEND_VAR                                                 !0
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMIs04%3A4%240'
          8        BIND_LEXICAL                                             ~4, !1
    6     9        SEND_VAL                                                 ~4
         10        SEND_VAL                                                 <false>
         11        DO_ICALL                                         $5      
         12        BOOL                                             ~3      $5
         13    > > RETURN                                                   ~3
    7    14*     > RETURN                                                   null

End of function any

Function %00%7Bclosure%7D%2Fin%2FMIs04%3A4%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/MIs04
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $bool, !1 = $item, !2 = $predicate
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
    5     3      > JMPNZ_EX                                         ~3      !0, ->9
          4    >   INIT_DYNAMIC_CALL                                        !2
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $4      
          7        BOOL                                             ~5      $4
          8        BOOL                                             ~3      ~5
          9    > > RETURN                                                   ~3
    6    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMIs04%3A4%240

Function all:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/MIs04
function name:  all
number of ops:  15
compiled vars:  !0 = $array, !1 = $predicate
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        COUNT                                            ~2      !0
          3        BOOL                                             ~3      ~2
          4      > JMPZ_EX                                          ~3      ~3, ->13
          5    >   INIT_FCALL                                               'array_reduce'
          6        SEND_VAR                                                 !0
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMIs04%3A10%241'
          8        BIND_LEXICAL                                             ~4, !1
   12     9        SEND_VAL                                                 ~4
         10        SEND_VAL                                                 <true>
         11        DO_ICALL                                         $5      
         12        BOOL                                             ~3      $5
         13    > > RETURN                                                   ~3
   13    14*     > RETURN                                                   null

End of function all

Function %00%7Bclosure%7D%2Fin%2FMIs04%3A10%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/MIs04
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $bool, !1 = $item, !2 = $predicate
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   11     3      > JMPZ_EX                                          ~3      !0, ->9
          4    >   INIT_DYNAMIC_CALL                                        !2
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $4      
          7        BOOL                                             ~5      $4
          8        BOOL                                             ~3      ~5
          9    > > RETURN                                                   ~3
   12    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMIs04%3A10%241

Function %00%7Bclosure%7D%2Fin%2FMIs04%3A28%242:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 4
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MIs04
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   29     1      > JMPZ                                                     !0, ->4
          2    >   QM_ASSIGN                                        ~1      'Yeop'
          3      > JMP                                                      ->5
          4    >   QM_ASSIGN                                        ~1      'Nope'
          5    > > RETURN                                                   ~1
   30     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMIs04%3A28%242

Function %00%7Bclosure%7D%2Fin%2FMIs04%3A30%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MIs04
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   RECV                                             !0      
   31     1      > RETURN                                                   !0
   32     2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMIs04%3A30%243

Function %00%7Bclosure%7D%2Fin%2FMIs04%3A34%244:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 4
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MIs04
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   35     1      > JMPZ                                                     !0, ->4
          2    >   QM_ASSIGN                                        ~1      'Yeop'
          3      > JMP                                                      ->5
          4    >   QM_ASSIGN                                        ~1      'Nope'
          5    > > RETURN                                                   ~1
   36     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMIs04%3A34%244

Function %00%7Bclosure%7D%2Fin%2FMIs04%3A36%245:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MIs04
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   RECV                                             !0      
   37     1      > RETURN                                                   !0
   38     2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMIs04%3A36%245

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.16 ms | 1415 KiB | 23 Q