3v4l.org

run code in 300+ PHP versions simultaneously
<?php $main_domains = ['example.co.uk','example.com','example.org']; $sub_domains = ['sub.example.com','ftp.example.org','ftp.example.co.uk','mail.example.com']; $results = []; array_walk( $sub_domains, function($subdomain) use ($main_domains, &$results) { foreach ($main_domains as $domain) { // or however you're checking if (strpos($subdomain, $domain) !== false) { $results[$domain][] = $subdomain; } } } ); var_dump($results);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sQXPX
function name:  (null)
number of ops:  14
compiled vars:  !0 = $main_domains, !1 = $sub_domains, !2 = $results
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, <array>
    7     3        INIT_FCALL                                               'array_walk'
    8     4        SEND_REF                                                 !1
    9     5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FsQXPX%3A9%240'
          6        BIND_LEXICAL                                             ~6, !0
          7        BIND_LEXICAL                                             ~6, !2
   16     8        SEND_VAL                                                 ~6
          9        DO_ICALL                                                 
   19    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FsQXPX%3A9%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 14
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/sQXPX
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $subdomain, !1 = $main_domains, !2 = $results, !3 = $domain
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   10     3      > FE_RESET_R                                       $4      !1, ->15
          4    > > FE_FETCH_R                                               $4, !3, ->15
   12     5    >   INIT_FCALL                                               'strpos'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !3
          8        DO_ICALL                                         $5      
          9        TYPE_CHECK                                  1018          $5
         10      > JMPZ                                                     ~6, ->14
   13    11    >   FETCH_DIM_W                                      $7      !2, !3
         12        ASSIGN_DIM                                               $7
         13        OP_DATA                                                  !0
   10    14    > > JMP                                                      ->4
         15    >   FE_FREE                                                  $4
   16    16      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FsQXPX%3A9%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.73 ms | 1401 KiB | 19 Q