3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[ { "id": "1", "country_id": "1", "spec_id": "1", "spec_children_name": "SUPER REDUCES RATE", "spec_children_first_col": "", "spec_children_second_col": "", "spec_children_third_col": "" }, { "id": "2", "country_id": "1", "spec_id": "1", "spec_children_name": "REDUCED RATE", "spec_children_first_col": "10% and 13%", "spec_children_second_col": "food, passenger transport, accommodotion, newspaper, pharmaceutical products,\u2026.(10%); plants, antiques, firewood, cinema, theatre,\u2026(13%)", "spec_children_third_col": "" }, { "id": "3", "country_id": "1", "spec_id": "1", "spec_children_name": "MEDIUM RATE", "spec_children_first_col": "", "spec_children_second_col": "", "spec_children_third_col": "" }, { "id": "4", "country_id": "1", "spec_id": "1", "spec_children_name": "STANDARD RATE", "spec_children_first_col": "20%", "spec_children_second_col": "other", "spec_children_third_col": "" }, { "id": "5", "country_id": "1", "spec_id": "1", "spec_children_name": "ZERO RATE", "spec_children_first_col": "", "spec_children_second_col": "", "spec_children_third_col": "" }, { "id": "104", "country_id": "2", "spec_id": "1", "spec_children_name": "REDUCED RATE", "spec_children_first_col": "TEXT 547", "spec_children_second_col": "TEXT 1000", "spec_children_third_col": "" } ]'; $objects = json_decode($json); $rules = ['spec_id' => 'ASC', 'spec_children_name' => 'DESC']; uasort($objects, function($a, $b) use ($rules) { foreach ($rules as $column => $order) { $left[] = $order === 'ASC' ? $a->$column : $b->$column; $right[] = $order === 'ASC' ? $b->$column : $a->$column; } return $left <=> $right; }); var_export($objects);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O60IS
function name:  (null)
number of ops:  16
compiled vars:  !0 = $json, !1 = $objects, !2 = $rules
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%0A%7B%0A++++%22id%22%3A+%221%22%2C%0A++++%22country_id%22%3A+%221%22%2C%0A++++%22spec_id%22%3A+%221%22%2C%0A++++%22spec_children_name%22%3A+%22SUPER+REDUCES+RATE%22%2C%0A++++%22spec_children_first_col%22%3A+%22%22%2C%0A++++%22spec_children_second_col%22%3A+%22%22%2C%0A++++%22spec_children_third_col%22%3A+%22%22%0A%7D%2C%0A%7B%0A++++%22id%22%3A+%222%22%2C%0A++++%22country_id%22%3A+%221%22%2C%0A++++%22spec_id%22%3A+%221%22%2C%0A++++%22spec_children_name%22%3A+%22REDUCED+RATE%22%2C%0A++++%22spec_children_first_col%22%3A+%2210%25+and+13%25%22%2C%0A++++%22spec_children_second_col%22%3A+%22food%2C+passenger+transport%2C+accommodotion%2C+newspaper%2C+pharmaceutical+products%2C%5Cu2026.%2810%25%29%3B+plants%2C+antiques%2C+firewood%2C+cinema%2C+theatre%2C%5Cu2026%2813%25%29%22%2C%0A++++%22spec_children_third_col%22%3A+%22%22%0A%7D%2C%0A%7B%0A++++%22id%22%3A+%223%22%2C%0A++++%22country_id%22%3A+%221%22%2C%0A++++%22spec_id%22%3A+%221%22%2C%0A++++%22spec_children_name%22%3A+%22MEDIUM+RATE%22%2C%0A++++%22spec_children_first_col%22%3A+%22%22%2C%0A++++%22spec_children_second_col%22%3A+%22%22%2C%0A++++%22spec_children_third_col%22%3A+%22%22%0A%7D%2C%0A%7B%0A++++%22id%22%3A+%224%22%2C%0A++++%22country_id%22%3A+%221%22%2C%0A++++%22spec_id%22%3A+%221%22%2C%0A++++%22spec_children_name%22%3A+%22STANDARD+RATE%22%2C%0A++++%22spec_children_first_col%22%3A+%2220%25%22%2C%0A++++%22spec_children_second_col%22%3A+%22other%22%2C%0A++++%22spec_children_third_col%22%3A+%22%22%0A%7D%2C%0A%7B%0A++++%22id%22%3A+%225%22%2C%0A++++%22country_id%22%3A+%221%22%2C%0A++++%22spec_id%22%3A+%221%22%2C%0A++++%22spec_children_name%22%3A+%22ZERO+RATE%22%2C%0A++++%22spec_children_first_col%22%3A+%22%22%2C%0A++++%22spec_children_second_col%22%3A+%22%22%2C%0A++++%22spec_children_third_col%22%3A+%22%22%0A%7D%2C%0A%7B%0A++++%22id%22%3A+%22104%22%2C%0A++++%22country_id%22%3A+%222%22%2C%0A++++%22spec_id%22%3A+%221%22%2C%0A++++%22spec_children_name%22%3A+%22REDUCED+RATE%22%2C%0A++++%22spec_children_first_col%22%3A+%22TEXT+547%22%2C%0A++++%22spec_children_second_col%22%3A+%22TEXT+1000%22%2C%0A++++%22spec_children_third_col%22%3A+%22%22%0A%7D%0A%5D'
   59     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
   61     5        ASSIGN                                                   !2, <array>
   63     6        INIT_FCALL                                               'uasort'
          7        SEND_REF                                                 !1
          8        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
          9        BIND_LEXICAL                                             ~7, !2
   69    10        SEND_VAL                                                 ~7
   63    11        DO_ICALL                                                 
   71    12        INIT_FCALL                                               'var_export'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                                 
         15      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 25
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 25
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
Branch analysis from position: 20
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/O60IS
function name:  {closure}
number of ops:  29
compiled vars:  !0 = $a, !1 = $b, !2 = $rules, !3 = $order, !4 = $column, !5 = $left, !6 = $right
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   64     3      > FE_RESET_R                                       $7      !2, ->25
          4    > > FE_FETCH_R                                       ~8      $7, !3, ->25
          5    >   ASSIGN                                                   !4, ~8
   65     6        IS_IDENTICAL                                             !3, 'ASC'
          7      > JMPZ                                                     ~11, ->11
          8    >   FETCH_OBJ_R                                      ~12     !0, !4
          9        QM_ASSIGN                                        ~13     ~12
         10      > JMP                                                      ->13
         11    >   FETCH_OBJ_R                                      ~14     !1, !4
         12        QM_ASSIGN                                        ~13     ~14
         13    >   ASSIGN_DIM                                               !5
         14        OP_DATA                                                  ~13
   66    15        IS_IDENTICAL                                             !3, 'ASC'
         16      > JMPZ                                                     ~16, ->20
         17    >   FETCH_OBJ_R                                      ~17     !1, !4
         18        QM_ASSIGN                                        ~18     ~17
         19      > JMP                                                      ->22
         20    >   FETCH_OBJ_R                                      ~19     !0, !4
         21        QM_ASSIGN                                        ~18     ~19
         22    >   ASSIGN_DIM                                               !6
         23        OP_DATA                                                  ~18
   64    24      > JMP                                                      ->4
         25    >   FE_FREE                                                  $7
   68    26        SPACESHIP                                        ~20     !5, !6
         27      > RETURN                                                   ~20
   69    28*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.82 ms | 1009 KiB | 16 Q