3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Products { public static function sortByPriceAscending($jsonString) { $info = json_decode($jsonString, true); usort($info, function($a, $b) { return $a['price'] - $b['price']; }); print_r($info); } } // For testing purposes (do not submit uncommented) echo Products::sortByPriceAscending('[{"name":"coffee","price":9.99},{"name":"eggs","price":1},{"name":"rice","price":4.04}]');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UJHK3
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_STATIC_METHOD_CALL                                  'Products', 'sortByPriceAscending'
          1        SEND_VAL                                                 '%5B%7B%22name%22%3A%22coffee%22%2C%22price%22%3A9.99%7D%2C%7B%22name%22%3A%22eggs%22%2C%22price%22%3A1%7D%2C%7B%22name%22%3A%22rice%22%2C%22price%22%3A4.04%7D%5D'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FUJHK3%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UJHK3
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        FETCH_DIM_R                                      ~2      !0, 'price'
          3        FETCH_DIM_R                                      ~3      !1, 'price'
          4        SUB                                              ~4      ~2, ~3
          5      > RETURN                                                   ~4
   10     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FUJHK3%3A7%240

Class Products:
Function sortbypriceascending:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UJHK3
function name:  sortByPriceAscending
number of ops:  15
compiled vars:  !0 = $jsonString, !1 = $info
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !1, $2
    7     6        INIT_FCALL                                               'usort'
          7        SEND_REF                                                 !1
          8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FUJHK3%3A7%240'
   10     9        SEND_VAL                                                 ~4
         10        DO_ICALL                                                 
   11    11        INIT_FCALL                                               'print_r'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
   12    14      > RETURN                                                   null

End of function sortbypriceascending

End of class Products.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.22 ms | 1396 KiB | 19 Q