3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{ "channel": { "id": "xxxxxxx", "field1": "A", "created_at": "2021-06-16T19:06:15+07:00", "updated_at": "2021-06-16T19:09:58+07:00", "last_entry_id": 459 }, "feeds": [ { "created_at": "2021-06-19T07:00:11+07:00", "entry_id": 1, "field1": "26.51" }, { "created_at": "2021-06-19T07:00:26+07:00", "entry_id": 2, "field1": "26.78" }, { "created_at": "2021-06-19T07:00:56+07:00", "entry_id": 3, "field1": "26.81" } ] }'; $feeds = json_decode($json, true)['feeds']; usort($feeds, function($a, $b) { return $b['field1'] <=> $a['field1']; }); $last = array_slice($feeds, -1)[0]; printf( 'max : %.2f %s - min: %.2f %s', round($feeds[0]['field1'], 2), $feeds[0]['created_at'], round($last['field1'], 2), $last['created_at'] );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A9b0u
function name:  (null)
number of ops:  40
compiled vars:  !0 = $json, !1 = $feeds, !2 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%0A++++%22channel%22%3A+%7B%0A++++++++%22id%22%3A+%22xxxxxxx%22%2C%0A++++++++%22field1%22%3A+%22A%22%2C%0A++++++++%22created_at%22%3A+%222021-06-16T19%3A06%3A15%2B07%3A00%22%2C%0A++++++++%22updated_at%22%3A+%222021-06-16T19%3A09%3A58%2B07%3A00%22%2C%0A++++++++%22last_entry_id%22%3A+459%0A++++%7D%2C%0A++++%22feeds%22%3A+%5B%0A++++++++%7B%0A++++++++++++%22created_at%22%3A+%222021-06-19T07%3A00%3A11%2B07%3A00%22%2C%0A++++++++++++%22entry_id%22%3A+1%2C%0A++++++++++++%22field1%22%3A+%2226.51%22%0A++++++++%7D%2C%0A++++++++%7B%0A++++++++++++%22created_at%22%3A+%222021-06-19T07%3A00%3A26%2B07%3A00%22%2C%0A++++++++++++%22entry_id%22%3A+2%2C%0A++++++++++++%22field1%22%3A+%2226.78%22%0A++++++++%7D%2C%0A++++++++%7B%0A++++++++++++%22created_at%22%3A+%222021-06-19T07%3A00%3A56%2B07%3A00%22%2C%0A++++++++++++%22entry_id%22%3A+3%2C%0A++++++++++++%22field1%22%3A+%2226.81%22%0A++++++++%7D%0A++++%5D%0A%7D'
   30     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $4      
          5        FETCH_DIM_R                                      ~5      $4, 'feeds'
          6        ASSIGN                                                   !1, ~5
   32     7        INIT_FCALL                                               'usort'
          8        SEND_REF                                                 !1
          9        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
   34    10        SEND_VAL                                                 ~7
   32    11        DO_ICALL                                                 
   36    12        INIT_FCALL                                               'array_slice'
         13        SEND_VAR                                                 !1
         14        SEND_VAL                                                 -1
         15        DO_ICALL                                         $9      
         16        FETCH_DIM_R                                      ~10     $9, 0
         17        ASSIGN                                                   !2, ~10
   38    18        INIT_FCALL                                               'printf'
   39    19        SEND_VAL                                                 'max+%3A+%25.2f+%25s+-+min%3A+%25.2f+%25s'
   40    20        INIT_FCALL                                               'round'
         21        FETCH_DIM_R                                      ~12     !1, 0
         22        FETCH_DIM_R                                      ~13     ~12, 'field1'
         23        SEND_VAL                                                 ~13
         24        SEND_VAL                                                 2
         25        DO_ICALL                                         $14     
         26        SEND_VAR                                                 $14
   41    27        FETCH_DIM_R                                      ~15     !1, 0
         28        FETCH_DIM_R                                      ~16     ~15, 'created_at'
         29        SEND_VAL                                                 ~16
   42    30        INIT_FCALL                                               'round'
         31        FETCH_DIM_R                                      ~17     !2, 'field1'
         32        SEND_VAL                                                 ~17
         33        SEND_VAL                                                 2
         34        DO_ICALL                                         $18     
         35        SEND_VAR                                                 $18
   43    36        FETCH_DIM_R                                      ~19     !2, 'created_at'
         37        SEND_VAL                                                 ~19
   38    38        DO_ICALL                                                 
   44    39      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A9b0u
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   33     2        FETCH_DIM_R                                      ~2      !1, 'field1'
          3        FETCH_DIM_R                                      ~3      !0, 'field1'
          4        SPACESHIP                                        ~4      ~2, ~3
          5      > RETURN                                                   ~4
   34     6*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
125.08 ms | 1009 KiB | 18 Q