3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ "a" => ['keycode' => '0001','date' => "2015-09-08"], "b" => ['keycode' => '0002','date' => "2015-09-05"], "c" => ['keycode' => '0003','date' => "2002-12-04"], "d" => ['keycode' => '0001','date' => "2015-09-01"], "e" => ['keycode' => '0001','date' => "2015-10-01"] ]; $needle = '0001'; $earliest = null; foreach ($array as $row) { if ($row['keycode'] === $needle && (!$earliest || $row['date'] < $earliest)) { $earliest = $row['date']; } } echo $earliest ?? "No qualifying rows for $needle";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 18
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 47) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 17
Branch analysis from position: 13
Branch analysis from position: 14
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/umaP9
function name:  (null)
number of ops:  25
compiled vars:  !0 = $array, !1 = $needle, !2 = $earliest, !3 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, '0001'
   13     2        ASSIGN                                                   !2, null
   14     3      > FE_RESET_R                                       $7      !0, ->18
          4    > > FE_FETCH_R                                               $7, !3, ->18
   15     5    >   FETCH_DIM_R                                      ~8      !3, 'keycode'
          6        IS_IDENTICAL                                     ~9      !1, ~8
          7      > JMPZ_EX                                          ~9      ~9, ->14
          8    >   BOOL_NOT                                         ~10     !2
          9      > JMPNZ_EX                                         ~10     ~10, ->13
         10    >   FETCH_DIM_R                                      ~11     !3, 'date'
         11        IS_SMALLER                                       ~12     ~11, !2
         12        BOOL                                             ~10     ~12
         13    >   BOOL                                             ~9      ~10
         14    > > JMPZ                                                     ~9, ->17
   16    15    >   FETCH_DIM_R                                      ~13     !3, 'date'
         16        ASSIGN                                                   !2, ~13
   14    17    > > JMP                                                      ->4
         18    >   FE_FREE                                                  $7
   19    19        COALESCE                                         ~15     !2
         20        NOP                                                      
         21        FAST_CONCAT                                      ~16     'No+qualifying+rows+for+', !1
         22        QM_ASSIGN                                        ~15     ~16
         23        ECHO                                                     ~15
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.83 ms | 1000 KiB | 13 Q