3v4l.org

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

Function isnumberpresentinarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 19
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/UjOEd
function name:  isNumberPresentInArray
number of ops:  22
compiled vars:  !0 = $a, !1 = $b, !2 = $v
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    6     2      > FE_RESET_R                                           $3      !0, ->19
          3    > > FE_FETCH_R                                                   $3, !2, ->19
    8     4    >   TYPE_CHECK                                      128          !2
          5      > JMPZ                                                         ~4, ->14
    9     6    >   INIT_FCALL_BY_NAME                                           'isNumberPresentInArray'
          7        SEND_VAR_EX                                                  !2
          8        SEND_VAR_EX                                                  !1
          9        DO_FCALL                                          0  $5      
         10      > JMPZ                                                         $5, ->13
   10    11    >   FE_FREE                                                      $3
         12      > RETURN                                                       <true>
    8    13    > > JMP                                                          ->18
   13    14    >   IS_EQUAL                                                     !2, !1
         15      > JMPZ                                                         ~6, ->18
   14    16    >   FE_FREE                                                      $3
         17      > RETURN                                                       <true>
    6    18    > > JMP                                                          ->3
         19    >   FE_FREE                                                      $3
   17    20      > RETURN                                                       <false>
   18    21*     > RETURN                                                       null

End of function isnumberpresentinarray

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
185.97 ms | 1962 KiB | 18 Q