3v4l.org

run code in 300+ PHP versions simultaneously
<?php $firstArray = array( array('startDate' => '05-05-2016', 'endDate' => '10-05-2016'), array('startDate' => '05-06-2016', 'endDate' => '10-07-2016'), array('startDate' => '05-08-2016', 'endDate' => '10-11-2016') ); $secondArray = array(array('date' => '07-05-2016'), array('date' => '12-07-2016'), array('date' => '12-11-2016')); function find_match($index){ global $firstArray, $secondArray; foreach($secondArray as $date){ if(strtotime($date['date']) > strtotime($firstArray[$index]['startDate']) && strtotime($date['date']) < strtotime($firstArray[$index]['endDate'])) return $date['date']; } return null; } foreach($firstArray as $key => $st_dates){ $date = find_match($key); echo ($date != null) ? $date : "No match Found."; echo '<br/>'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 17
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/7ZKnM
function name:  (null)
number of ops:  19
compiled vars:  !0 = $firstArray, !1 = $secondArray, !2 = $st_dates, !3 = $key, !4 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   19     2      > FE_RESET_R                                       $7      !0, ->17
          3    > > FE_FETCH_R                                       ~8      $7, !2, ->17
          4    >   ASSIGN                                                   !3, ~8
   20     5        INIT_FCALL                                               'find_match'
          6        SEND_VAR                                                 !3
          7        DO_FCALL                                      0  $10     
          8        ASSIGN                                                   !4, $10
   21     9        IS_NOT_EQUAL                                             !4, null
         10      > JMPZ                                                     ~12, ->13
         11    >   QM_ASSIGN                                        ~13     !4
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~13     'No+match+Found.'
         14    >   ECHO                                                     ~13
   22    15        ECHO                                                     '%3Cbr%2F%3E'
   19    16      > JMP                                                      ->3
         17    >   FE_FREE                                                  $7
   23    18      > RETURN                                                   1

Function find_match:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 32
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 32
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 27
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 31
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 27
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/7ZKnM
function name:  find_match
number of ops:  35
compiled vars:  !0 = $index, !1 = $firstArray, !2 = $secondArray, !3 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        BIND_GLOBAL                                              !1, 'firstArray'
          2        BIND_GLOBAL                                              !2, 'secondArray'
   12     3      > FE_RESET_R                                       $4      !2, ->32
          4    > > FE_FETCH_R                                               $4, !3, ->32
   13     5    >   INIT_FCALL                                               'strtotime'
          6        FETCH_DIM_R                                      ~5      !3, 'date'
          7        SEND_VAL                                                 ~5
          8        DO_ICALL                                         $6      
          9        INIT_FCALL                                               'strtotime'
         10        FETCH_DIM_R                                      ~7      !1, !0
         11        FETCH_DIM_R                                      ~8      ~7, 'startDate'
         12        SEND_VAL                                                 ~8
         13        DO_ICALL                                         $9      
         14        IS_SMALLER                                       ~10     $9, $6
         15      > JMPZ_EX                                          ~10     ~10, ->27
         16    >   INIT_FCALL                                               'strtotime'
         17        FETCH_DIM_R                                      ~11     !3, 'date'
         18        SEND_VAL                                                 ~11
         19        DO_ICALL                                         $12     
         20        INIT_FCALL                                               'strtotime'
         21        FETCH_DIM_R                                      ~13     !1, !0
         22        FETCH_DIM_R                                      ~14     ~13, 'endDate'
         23        SEND_VAL                                                 ~14
         24        DO_ICALL                                         $15     
         25        IS_SMALLER                                       ~16     $12, $15
         26        BOOL                                             ~10     ~16
         27    > > JMPZ                                                     ~10, ->31
   14    28    >   FETCH_DIM_R                                      ~17     !3, 'date'
         29        FE_FREE                                                  $4
         30      > RETURN                                                   ~17
   12    31    > > JMP                                                      ->4
         32    >   FE_FREE                                                  $4
   16    33      > RETURN                                                   null
   17    34*     > RETURN                                                   null

End of function find_match

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.62 ms | 1444 KiB | 15 Q