3v4l.org

run code in 300+ PHP versions simultaneously
<?php function in_array_cmp($needle, array $haystack, callable $cmp) { foreach ($haystack as $value) { if ($cmp($needle, $value)) { return true; } } return false; } $cmpround = function($a, $b) { return round($a, 1) == round($b, 1); }; $array_1 = range(1, 1.9, 0.1); var_dump(in_array_cmp(1.7, $array_1, $cmpround)); $array_2 = range(0, 0.9, 0.1); var_dump(in_array_cmp(0.3, $array_2, $cmpround)); var_dump(in_array_cmp(0.6, $array_2, $cmpround)); var_dump(in_array_cmp(0.7, $array_2, $cmpround)); //=>it return false;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dZq7U
function name:  (null)
number of ops:  47
compiled vars:  !0 = $cmpround, !1 = $array_1, !2 = $array_2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FdZq7U%3A12%240'
          1        ASSIGN                                                   !0, ~3
   14     2        INIT_FCALL                                               'range'
          3        SEND_VAL                                                 1
          4        SEND_VAL                                                 1.9
          5        SEND_VAL                                                 0.1
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !1, $5
   15     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL                                               'in_array_cmp'
         10        SEND_VAL                                                 1.7
         11        SEND_VAR                                                 !1
         12        SEND_VAR                                                 !0
         13        DO_FCALL                                      0  $7      
         14        SEND_VAR                                                 $7
         15        DO_ICALL                                                 
   17    16        INIT_FCALL                                               'range'
         17        SEND_VAL                                                 0
         18        SEND_VAL                                                 0.9
         19        SEND_VAL                                                 0.1
         20        DO_ICALL                                         $9      
         21        ASSIGN                                                   !2, $9
   18    22        INIT_FCALL                                               'var_dump'
         23        INIT_FCALL                                               'in_array_cmp'
         24        SEND_VAL                                                 0.3
         25        SEND_VAR                                                 !2
         26        SEND_VAR                                                 !0
         27        DO_FCALL                                      0  $11     
         28        SEND_VAR                                                 $11
         29        DO_ICALL                                                 
   19    30        INIT_FCALL                                               'var_dump'
         31        INIT_FCALL                                               'in_array_cmp'
         32        SEND_VAL                                                 0.6
         33        SEND_VAR                                                 !2
         34        SEND_VAR                                                 !0
         35        DO_FCALL                                      0  $13     
         36        SEND_VAR                                                 $13
         37        DO_ICALL                                                 
   20    38        INIT_FCALL                                               'var_dump'
         39        INIT_FCALL                                               'in_array_cmp'
         40        SEND_VAL                                                 0.7
         41        SEND_VAR                                                 !2
         42        SEND_VAR                                                 !0
         43        DO_FCALL                                      0  $15     
         44        SEND_VAR                                                 $15
         45        DO_ICALL                                                 
   22    46      > RETURN                                                   1

Function in_array_cmp:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/dZq7U
function name:  in_array_cmp
number of ops:  16
compiled vars:  !0 = $needle, !1 = $haystack, !2 = $cmp, !3 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    4     3      > FE_RESET_R                                       $4      !1, ->13
          4    > > FE_FETCH_R                                               $4, !3, ->13
    5     5    >   INIT_DYNAMIC_CALL                                        !2
          6        SEND_VAR_EX                                              !0
          7        SEND_VAR_EX                                              !3
          8        DO_FCALL                                      0  $5      
          9      > JMPZ                                                     $5, ->12
    6    10    >   FE_FREE                                                  $4
         11      > RETURN                                                   <true>
    4    12    > > JMP                                                      ->4
         13    >   FE_FREE                                                  $4
    9    14      > RETURN                                                   <false>
   10    15*     > RETURN                                                   null

End of function in_array_cmp

Function %00%7Bclosure%7D%2Fin%2FdZq7U%3A12%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dZq7U
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        INIT_FCALL                                               'round'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 1
          5        DO_ICALL                                         $2      
          6        INIT_FCALL                                               'round'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 1
          9        DO_ICALL                                         $3      
         10        IS_EQUAL                                         ~4      $2, $3
         11      > RETURN                                                   ~4
         12*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FdZq7U%3A12%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.79 ms | 1403 KiB | 23 Q