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_values(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 = 27
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 27
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: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/LLaIS
function name:  (null)
number of ops:  32
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, ->27
          4    > > FE_FETCH_R                                               $7, !3, ->27
   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_values'
         13        INIT_FCALL                                               'array_filter'
         14        SEND_VAR                                                 !0
         15        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FLLaIS%3A28%240'
         16        BIND_LEXICAL                                             ~11, !3
   32    17        SEND_VAL                                                 ~11
         18        DO_ICALL                                         $12     
         19        SEND_VAR                                                 $12
         20        DO_ICALL                                         $13     
   28    21        ASSIGN_DIM                                               !1
   32    22        OP_DATA                                                  $13
   34    23        FETCH_DIM_R                                      ~15     !3, 'task_date'
         24        ASSIGN_DIM                                               !2
         25        OP_DATA                                                  ~15
   21    26      > JMP                                                      ->4
         27    >   FE_FREE                                                  $7
   38    28        INIT_FCALL                                               'var_dump'
         29        SEND_VAR                                                 !1
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FLLaIS%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/LLaIS
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%2FLLaIS%3A28%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.44 ms | 1400 KiB | 21 Q