3v4l.org

run code in 500+ PHP versions simultaneously
<?php /** * Returns the index of the first match or -1 if not found. */ function arraySearch(array $array, string $search): int { foreach ($array as $key => $value) { if (strpos($value, $search) !== false) { return $key; } } return -1; } $unique_domains = [ 'www.crownworldwide.com', 'www.acquisition.gov', 'www.hemisphere-freight.com', 'www.businessinsider.com', 'www.oceansidelogistics.com', 'mixjet.aero', 'www.airindiaexpress.in', 'rlglobal.com', 'www.metroshipping.co.uk', 'www.flexport.com' ]; $position = arraySearch($unique_domains, 'flexport.com'); echo $position; // 9
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kTv9X
function name:  (null)
number of ops:  8
compiled vars:  !0 = $unique_domains, !1 = $position
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                       !0, <array>
   28     1        INIT_FCALL                                                   'arraysearch'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     'flexport.com'
          4        DO_FCALL                                          0  $3      
          5        ASSIGN                                                       !1, $3
   29     6        ECHO                                                         !1
          7      > RETURN                                                       1

Function arraysearch:
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 = 8, Position 2 = 11
Branch analysis from position: 8
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/kTv9X
function name:  arraySearch
number of ops:  16
compiled vars:  !0 = $array, !1 = $search, !2 = $value, !3 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    7     2      > FE_RESET_R                                           $4      !0, ->12
          3    > > FE_FETCH_R                                           ~5      $4, !2, ->12
          4    >   ASSIGN                                                       !3, ~5
    8     5        FRAMELESS_ICALL_2                strpos              ~7      !2, !1
          6        TYPE_CHECK                                      1018          ~7
          7      > JMPZ                                                         ~8, ->11
    9     8    >   VERIFY_RETURN_TYPE                                           !3
          9        FE_FREE                                                      $4
         10      > RETURN                                                       !3
    7    11    > > JMP                                                          ->3
         12    >   FE_FREE                                                      $4
   12    13      > RETURN                                                       -1
   13    14*       VERIFY_RETURN_TYPE                                           
         15*     > RETURN                                                       null

End of function arraysearch

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
155.87 ms | 1850 KiB | 14 Q