3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str ='[{ "id": 1, "time": "2018-12-16", "pages_indexed": 1024 }, { "id": 2, "time": "2018-12-12", "something": 1024 }, { "id": 3, "time": "2018-12-09", "something": 7 }, { "id": 13, "time": "2018-11-08", "something": 7 }, { "id": 12, "time": "2018-11-12", "something": 7 }]'; $arr = json_decode($str, true); $time = array_column($arr, "time"); array_multisort($time, SORT_DESC, $arr); foreach(array_reverse($arr) as $sub){ $result[substr($sub["time"], 0, 7)]= $sub; } Var_dump($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 30
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 30
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/RhiO9
function name:  (null)
number of ops:  35
compiled vars:  !0 = $str, !1 = $arr, !2 = $time, !3 = $sub, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%7B%0A%22id%22%3A+1%2C%0A%22time%22%3A+%222018-12-16%22%2C%0A%22pages_indexed%22%3A+1024%0A%7D%2C%0A%7B%0A%22id%22%3A+2%2C%0A%22time%22%3A+%222018-12-12%22%2C%0A%22something%22%3A+1024%0A%7D%2C%0A%7B%0A%22id%22%3A+3%2C%0A%22time%22%3A+%222018-12-09%22%2C%0A%22something%22%3A+7%0A%7D%2C%0A%7B%0A%22id%22%3A+13%2C%0A%22time%22%3A+%222018-11-08%22%2C%0A%22something%22%3A+7%0A%7D%2C%0A%7B%0A%22id%22%3A+12%2C%0A%22time%22%3A+%222018-11-12%22%2C%0A%22something%22%3A+7%0A%7D%5D'
   29     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !1, $6
   30     6        INIT_FCALL                                               'array_column'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 'time'
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !2, $8
   31    11        INIT_FCALL                                               'array_multisort'
         12        SEND_REF                                                 !2
         13        SEND_VAL                                                 3
         14        SEND_REF                                                 !1
         15        DO_ICALL                                                 
   33    16        INIT_FCALL                                               'array_reverse'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $11     
         19      > FE_RESET_R                                       $12     $11, ->30
         20    > > FE_FETCH_R                                               $12, !3, ->30
   34    21    >   INIT_FCALL                                               'substr'
         22        FETCH_DIM_R                                      ~13     !3, 'time'
         23        SEND_VAL                                                 ~13
         24        SEND_VAL                                                 0
         25        SEND_VAL                                                 7
         26        DO_ICALL                                         $14     
         27        ASSIGN_DIM                                               !4, $14
         28        OP_DATA                                                  !3
   33    29      > JMP                                                      ->20
         30    >   FE_FREE                                                  $12
   37    31        INIT_FCALL                                               'var_dump'
         32        SEND_VAR                                                 !4
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.49 ms | 1024 KiB | 19 Q