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'; usort($array, fn($a, $b) => [$a['keycode'] !== $needle, $a['date']] <=> [$b['keycode'] !== $needle, $b['date']]); echo $array[0]['keycode'] === $needle ? $array[0]['date'] : "No qualifying rows for $needle";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uqrri
function name:  (null)
number of ops:  21
compiled vars:  !0 = $array, !1 = $needle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, '0001'
   13     2        INIT_FCALL                                               'usort'
          3        SEND_REF                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          5        BIND_LEXICAL                                             ~4, !1
          6        SEND_VAL                                                 ~4
          7        DO_ICALL                                                 
   15     8        FETCH_DIM_R                                      ~6      !0, 0
          9        FETCH_DIM_R                                      ~7      ~6, 'keycode'
         10        IS_IDENTICAL                                             !1, ~7
         11      > JMPZ                                                     ~8, ->16
         12    >   FETCH_DIM_R                                      ~9      !0, 0
         13        FETCH_DIM_R                                      ~10     ~9, 'date'
         14        QM_ASSIGN                                        ~11     ~10
         15      > JMP                                                      ->19
         16    >   NOP                                                      
         17        FAST_CONCAT                                      ~12     'No+qualifying+rows+for+', !1
         18        QM_ASSIGN                                        ~11     ~12
         19    >   ECHO                                                     ~11
         20      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uqrri
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $a, !1 = $b, !2 = $needle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        FETCH_DIM_R                                      ~3      !0, 'keycode'
          4        IS_NOT_IDENTICAL                                 ~4      !2, ~3
          5        INIT_ARRAY                                       ~5      ~4
          6        FETCH_DIM_R                                      ~6      !0, 'date'
          7        ADD_ARRAY_ELEMENT                                ~5      ~6
          8        FETCH_DIM_R                                      ~7      !1, 'keycode'
          9        IS_NOT_IDENTICAL                                 ~8      !2, ~7
         10        INIT_ARRAY                                       ~9      ~8
         11        FETCH_DIM_R                                      ~10     !1, 'date'
         12        ADD_ARRAY_ELEMENT                                ~9      ~10
         13        SPACESHIP                                        ~11     ~5, ~9
         14      > RETURN                                                   ~11
         15*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
208.29 ms | 1007 KiB | 14 Q