3v4l.org

run code in 500+ PHP versions simultaneously
<?php function position($s) { $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' ]; return array_keys(array_filter($unique_domains, function($elm) use ($s){ if (preg_match('/'.$s.'/', $elm)) { return true; } return false; }))[0] ?? null; } print_r(position('flexport.com')); // 9 echo '<br/>'; print_r(position('www.flexport.com')); // 9 echo '<br/>'; print_r(position('.com')); // 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NCapg
function name:  (null)
number of ops:  21
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   INIT_FCALL                                                   'print_r'
          1        INIT_FCALL                                                   'position'
          2        SEND_VAL                                                     'flexport.com'
          3        DO_FCALL                                          0  $0      
          4        SEND_VAR                                                     $0
          5        DO_ICALL                                                     
   26     6        ECHO                                                         '%3Cbr%2F%3E'
   27     7        INIT_FCALL                                                   'print_r'
          8        INIT_FCALL                                                   'position'
          9        SEND_VAL                                                     'www.flexport.com'
         10        DO_FCALL                                          0  $2      
         11        SEND_VAR                                                     $2
         12        DO_ICALL                                                     
   28    13        ECHO                                                         '%3Cbr%2F%3E'
   29    14        INIT_FCALL                                                   'print_r'
         15        INIT_FCALL                                                   'position'
         16        SEND_VAL                                                     '.com'
         17        DO_FCALL                                          0  $4      
         18        SEND_VAR                                                     $4
         19        DO_ICALL                                                     
         20      > RETURN                                                       1

Function position:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NCapg
function name:  position
number of ops:  16
compiled vars:  !0 = $s, !1 = $unique_domains
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        ASSIGN                                                       !1, <array>
   17     2        INIT_FCALL                                                   'array_keys'
          3        INIT_FCALL                                                   'array_filter'
          4        SEND_VAR                                                     !1
          5        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
          6        BIND_LEXICAL                                                 ~3, !0
   22     7        SEND_VAL                                                     ~3
   17     8        DO_ICALL                                             $4      
   22     9        SEND_VAR                                                     $4
   17    10        DO_ICALL                                             $5      
   22    11        FETCH_DIM_IS                                         ~6      $5, 0
         12        COALESCE                                             ~7      ~6
         13        QM_ASSIGN                                            ~7      null
         14      > RETURN                                                       ~7
   23    15*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NCapg
function name:  {closure:position():17}
number of ops:  9
compiled vars:  !0 = $elm, !1 = $s
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
   18     2        CONCAT                                               ~2      '%2F', !1
          3        CONCAT                                               ~3      ~2, '%2F'
          4        FRAMELESS_ICALL_2                preg_match          ~4      ~3, !0
          5      > JMPZ                                                         ~4, ->7
   19     6    > > RETURN                                                       <true>
   21     7    > > RETURN                                                       <false>
   22     8*     > RETURN                                                       null

End of Dynamic Function 0

End of function position

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
218.95 ms | 1862 KiB | 19 Q