3v4l.org

run code in 300+ PHP versions simultaneously
<?php // these are subarrays containing 1 element each $json = '[{"rate":3},{"rate":4},{"rate":3},{"rate":5}]'; // decode it to an array $array = json_decode($json, true); // extract the "rate" column values from each subarray and sum them echo array_sum(array_column($array, 'rate'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9APjO
function name:  (null)
number of ops:  15
compiled vars:  !0 = $json, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%7B%22rate%22%3A3%7D%2C%7B%22rate%22%3A4%7D%2C%7B%22rate%22%3A3%7D%2C%7B%22rate%22%3A5%7D%5D'
    6     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
    9     6        INIT_FCALL                                               'array_sum'
          7        INIT_FCALL                                               'array_column'
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 'rate'
         10        DO_ICALL                                         $5      
         11        SEND_VAR                                                 $5
         12        DO_ICALL                                         $6      
         13        ECHO                                                     $6
         14      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
254.44 ms | 1001 KiB | 16 Q