3v4l.org

run code in 500+ PHP versions simultaneously
<?php $data = [ 0 => [ 'order' => 3, 'userId' => 'b3cef82a-ab65-4a0f-9e4b-3ad1d0324532', 'createdAt' => '2021-09-24T03:29:37.000Z', 'updatedAt' => '2021-09-24T03:29:37.000Z', ], 1 => [ 'order' => 2, 'userId' => '2955e28b-4d26-4992-9b5e-b300529dsas3', 'createdAt' => '2021-09-24T03:22:32.000Z', 'updatedAt' => '2021-09-24T03:22:32.000Z', ], 2 => [ 'order' => 3, 'userId' => 'wert5678-b85c-4802-b53f-cbdfe9515ty6b', 'createdAt' => '2021-09-01T10:13:45.000Z', 'updatedAt' => '2021-09-01T10:13:45.000Z', ], ]; $dataReal = null; foreach ($data as $v) { if( $v['order'] == 3 && // check for order ( $dataReal === null || // dataReal is empty strtotime($dataReal['createdAt']) < strtotime($v['createdAt']) // override if date is newer ) ) { $dataReal = $v; } } print_r($dataReal);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 23
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 20
Branch analysis from position: 7
2 jumps found. (Code = 47) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 22
Branch analysis from position: 19
Branch analysis from position: 20
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/p6gnq
function name:  (null)
number of ops:  28
compiled vars:  !0 = $data, !1 = $dataReal, !2 = $v
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   25     1        ASSIGN                                                       !1, null
   26     2      > FE_RESET_R                                           $5      !0, ->23
          3    > > FE_FETCH_R                                                   $5, !2, ->23
   28     4    >   FETCH_DIM_R                                          ~6      !2, 'order'
          5        IS_EQUAL                                             ~7      ~6, 3
          6      > JMPZ_EX                                              ~7      ~7, ->20
   30     7    >   TYPE_CHECK                                        2  ~8      !1
          8      > JMPNZ_EX                                             ~8      ~8, ->19
   31     9    >   INIT_FCALL                                                   'strtotime'
         10        FETCH_DIM_R                                          ~9      !1, 'createdAt'
         11        SEND_VAL                                                     ~9
         12        DO_ICALL                                             $10     
         13        INIT_FCALL                                                   'strtotime'
         14        FETCH_DIM_R                                          ~11     !2, 'createdAt'
         15        SEND_VAL                                                     ~11
         16        DO_ICALL                                             $12     
         17        IS_SMALLER                                           ~13     $10, $12
         18        BOOL                                                 ~8      ~13
         19    >   BOOL                                                 ~7      ~8
         20    > > JMPZ                                                         ~7, ->22
   35    21    >   ASSIGN                                                       !1, !2
   26    22    > > JMP                                                          ->3
         23    >   FE_FREE                                                      $5
   39    24        INIT_FCALL                                                   'print_r'
         25        SEND_VAR                                                     !1
         26        DO_ICALL                                                     
         27      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.83 ms | 2061 KiB | 15 Q