3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Products { public static function sortByPriceAscending($jsonString) { $info = json_decode($jsonString, true); usort($array, "cmp"); print_r($info); } public function cmp($a, $b) { return strcmp($a["price"], $b["price"]); } } // For testing purposes (do not submit uncommented) echo Products::sortByPriceAscending('[{"name":"eggs","price":1},{"name":"coffee","price":9.99},{"name":"rice","price":4.04}]');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/41VT5
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_STATIC_METHOD_CALL                                  'Products', 'sortByPriceAscending'
          1        SEND_VAL                                                 '%5B%7B%22name%22%3A%22eggs%22%2C%22price%22%3A1%7D%2C%7B%22name%22%3A%22coffee%22%2C%22price%22%3A9.99%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/41VT5
function name:  sortByPriceAscending
number of ops:  14
compiled vars:  !0 = $jsonString, !1 = $info, !2 = $array
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                                         $3      
          5        ASSIGN                                                   !1, $3
    7     6        INIT_FCALL                                               'usort'
          7        SEND_REF                                                 !2
          8        SEND_VAL                                                 'cmp'
          9        DO_ICALL                                                 
    8    10        INIT_FCALL                                               'print_r'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                                 
   11    13      > RETURN                                                   null

End of function sortbypriceascending

Function cmp:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/41VT5
function name:  cmp
number of ops:  10
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        INIT_FCALL                                               'strcmp'
          3        FETCH_DIM_R                                      ~2      !0, 'price'
          4        SEND_VAL                                                 ~2
          5        FETCH_DIM_R                                      ~3      !1, 'price'
          6        SEND_VAL                                                 ~3
          7        DO_ICALL                                         $4      
          8      > RETURN                                                   $4
   16     9*     > RETURN                                                   null

End of function cmp

End of class Products.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.94 ms | 1009 KiB | 17 Q