3v4l.org

run code in 500+ 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 = 27
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 27
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/RhiO9
function name:  (null)
number of ops:  32
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, ->27
         20    > > FE_FETCH_R                                                   $12, !3, ->27
   34    21    >   FETCH_DIM_R                                          ~13     !3, 'time'
         22        FRAMELESS_ICALL_3                substr              ~14     ~13, 0
         23        OP_DATA                                                      7
         24        ASSIGN_DIM                                                   !4, ~14
         25        OP_DATA                                                      !3
   33    26      > JMP                                                          ->20
         27    >   FE_FREE                                                      $12
   37    28        INIT_FCALL                                                   'var_dump'
         29        SEND_VAR                                                     !4
         30        DO_ICALL                                                     
         31      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
279.52 ms | 2089 KiB | 18 Q