3v4l.org

run code in 300+ PHP versions simultaneously
<?php function strpos_array($haystack, $needles) { if ( is_array($needles) ) { foreach ($needles as $str) { if ( is_array($str) ) { $pos = strpos_array($haystack, $str); } else { $pos = strpos($haystack, $str); } if ($pos !== FALSE) { return $pos; } } } else { return strpos($haystack, $needles); } } // Test echo strpos_array('This is a test', array('test', 'drive')); // Output is 10
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IQR76
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'strpos_array'
          1        SEND_VAL                                                 'This+is+a+test'
          2        SEND_VAL                                                 <array>
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
          5      > RETURN                                                   1

Function strpos_array:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 26
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 24
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 24
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
Branch analysis from position: 23
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IQR76
function name:  strpos_array
number of ops:  32
compiled vars:  !0 = $haystack, !1 = $needles, !2 = $str, !3 = $pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        TYPE_CHECK                                  128          !1
          3      > JMPZ                                                     ~4, ->26
    5     4    > > FE_RESET_R                                       $5      !1, ->24
          5    > > FE_FETCH_R                                               $5, !2, ->24
    6     6    >   TYPE_CHECK                                  128          !2
          7      > JMPZ                                                     ~6, ->14
    7     8    >   INIT_FCALL_BY_NAME                                       'strpos_array'
          9        SEND_VAR_EX                                              !0
         10        SEND_VAR_EX                                              !2
         11        DO_FCALL                                      0  $7      
         12        ASSIGN                                                   !3, $7
         13      > JMP                                                      ->19
    9    14    >   INIT_FCALL                                               'strpos'
         15        SEND_VAR                                                 !0
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $9      
         18        ASSIGN                                                   !3, $9
   11    19    >   TYPE_CHECK                                  1018          !3
         20      > JMPZ                                                     ~11, ->23
   12    21    >   FE_FREE                                                  $5
         22      > RETURN                                                   !3
    5    23    > > JMP                                                      ->5
         24    >   FE_FREE                                                  $5
         25      > JMP                                                      ->31
   16    26    >   INIT_FCALL                                               'strpos'
         27        SEND_VAR                                                 !0
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                         $12     
         30      > RETURN                                                   $12
   18    31    > > RETURN                                                   null

End of function strpos_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.99 ms | 1403 KiB | 16 Q