3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ [ 'record_id' => 3, 'task_date' => '2018-10-02' ], [ 'record_id' => 5, 'task_date' => '2018-10-02' ], [ 'record_id' => 1, 'task_date' => '2018-09-27' ] ]; $out = []; $datesIterated = []; foreach ($data as $date) { if(in_array($date['task_date'], $datesIterated)) { continue; } $out[] = array_filter($data, function($item) use ($date) { if ($item['task_date'] == $date['task_date']) { return $item; } }); $datesIterated[] = $date['task_date']; } var_dump($out);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 24
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/YkMYR
function name:  (null)
number of ops:  29
compiled vars:  !0 = $data, !1 = $out, !2 = $datesIterated, !3 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   18     1        ASSIGN                                                   !1, <array>
   19     2        ASSIGN                                                   !2, <array>
   21     3      > FE_RESET_R                                       $7      !0, ->24
          4    > > FE_FETCH_R                                               $7, !3, ->24
   23     5    >   INIT_FCALL                                               'in_array'
          6        FETCH_DIM_R                                      ~8      !3, 'task_date'
          7        SEND_VAL                                                 ~8
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                         $9      
         10      > JMPZ                                                     $9, ->12
   24    11    > > JMP                                                      ->4
   28    12    >   INIT_FCALL                                               'array_filter'
         13        SEND_VAR                                                 !0
         14        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FYkMYR%3A28%240'
         15        BIND_LEXICAL                                             ~11, !3
   32    16        SEND_VAL                                                 ~11
         17        DO_ICALL                                         $12     
   28    18        ASSIGN_DIM                                               !1
   32    19        OP_DATA                                                  $12
   34    20        FETCH_DIM_R                                      ~14     !3, 'task_date'
         21        ASSIGN_DIM                                               !2
         22        OP_DATA                                                  ~14
   21    23      > JMP                                                      ->4
         24    >   FE_FREE                                                  $7
   38    25        INIT_FCALL                                               'var_dump'
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FYkMYR%3A28%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkMYR
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $item, !1 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   29     2        FETCH_DIM_R                                      ~2      !0, 'task_date'
          3        FETCH_DIM_R                                      ~3      !1, 'task_date'
          4        IS_EQUAL                                                 ~2, ~3
          5      > JMPZ                                                     ~4, ->7
   30     6    > > RETURN                                                   !0
   32     7    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FYkMYR%3A28%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.41 ms | 1400 KiB | 19 Q