3v4l.org

run code in 500+ 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); $column = 'spec_children_name'; $direction = 'asc'; $reverser = $direction === 'asc' ? 1 : -1; uasort($objects, function($a, $b) use ($column, $reverser) { return $reverser * ($a->$column <=> $b->$column); }); var_export($objects);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EDK2W
function name:  (null)
number of ops:  24
compiled vars:  !0 = $json, !1 = $objects, !2 = $column, !3 = $direction, !4 = $reverser
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                                             $6      
          4        ASSIGN                                                       !1, $6
   61     5        ASSIGN                                                       !2, 'spec_children_name'
   62     6        ASSIGN                                                       !3, 'asc'
   63     7        IS_IDENTICAL                                                 !3, 'asc'
          8      > JMPZ                                                         ~10, ->11
          9    >   QM_ASSIGN                                            ~11     1
         10      > JMP                                                          ->12
         11    >   QM_ASSIGN                                            ~11     -1
         12    >   ASSIGN                                                       !4, ~11
   65    13        INIT_FCALL                                                   'uasort'
         14        SEND_REF                                                     !1
         15        DECLARE_LAMBDA_FUNCTION                              ~13     [0]
         16        BIND_LEXICAL                                                 ~13, !2
         17        BIND_LEXICAL                                                 ~13, !4
   67    18        SEND_VAL                                                     ~13
   65    19        DO_ICALL                                                     
   69    20        INIT_FCALL                                                   'var_export'
         21        SEND_VAR                                                     !1
         22        DO_ICALL                                                     
         23      > 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/EDK2W
function name:  {closure:/in/EDK2W:65}
number of ops:  10
compiled vars:  !0 = $a, !1 = $b, !2 = $column, !3 = $reverser
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   65     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
          3        BIND_STATIC                                                  !3
   66     4        FETCH_OBJ_R                                          ~4      !0, !2
          5        FETCH_OBJ_R                                          ~5      !1, !2
          6        SPACESHIP                                            ~6      ~4, ~5
          7        MUL                                                  ~7      !3, ~6
          8      > RETURN                                                       ~7
   67     9*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.83 ms | 2505 KiB | 15 Q