3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Products { public static function sortByPriceAscending($jsonString) { $info = json_decode($jsonString, true); print_r($info); 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/ivui3
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     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

Class Products:
Function sortbypriceascending:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ivui3
function name:  sortByPriceAscending
number of ops:  18
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                                               'print_r'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
    8     9        INIT_FCALL                                               'usort'
         10        SEND_REF                                                 !1
         11        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
   11    12        SEND_VAL                                                 ~5
    8    13        DO_ICALL                                                 
   12    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                                 
   13    17      > RETURN                                                   null


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

End of Dynamic Function 0

End of function sortbypriceascending

End of class Products.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.41 ms | 1003 KiB | 16 Q