3v4l.org

run code in 500+ PHP versions simultaneously
<?php // what i wanna do with this script is for each color, create an array that has the total price(my table has some items that have the same color but with different prices) $a = array(); while($row = mysqli_fetch_assoc($result)) { // create an array of each color, eg: $a["black"] $a["$row[color]"] = array(); // if the price key in the $a["black"] exists then add its value to the new one if(array_key_exists("price", $a["$row[color]"])) { $a["$row[color]"]["price"] += $row["price"]; } else { $a["$row[color]"]["price"] = $row["price"]; } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 2
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 2
Branch analysis from position: 29
Branch analysis from position: 2
filename:       /in/6NfOm
function name:  (null)
number of ops:  30
compiled vars:  !0 = $a, !1 = $row, !2 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                       !0, <array>
    5     1      > JMP                                                          ->24
    8     2    >   FETCH_DIM_R                                          ~4      !1, 'color'
          3        CAST                                              6  ~5      ~4
          4        ASSIGN_DIM                                                   !0, ~5
          5        OP_DATA                                                      <array>
   10     6        FETCH_DIM_R                                          ~7      !1, 'color'
          7        CAST                                              6  ~8      ~7
          8        FETCH_DIM_R                                          ~9      !0, ~8
          9        ARRAY_KEY_EXISTS                                             'price', ~9
         10      > JMPZ                                                         ~10, ->18
   12    11    >   FETCH_DIM_R                                          ~11     !1, 'color'
         12        CAST                                              6  ~12     ~11
         13        FETCH_DIM_R                                          ~15     !1, 'price'
         14        FETCH_DIM_RW                                         $13     !0, ~12
         15        ASSIGN_DIM_OP                    +=               1          $13, 'price'
         16        OP_DATA                                                      ~15
   10    17      > JMP                                                          ->24
   16    18    >   FETCH_DIM_R                                          ~16     !1, 'color'
         19        CAST                                              6  ~17     ~16
         20        FETCH_DIM_R                                          ~20     !1, 'price'
         21        FETCH_DIM_W                                          $18     !0, ~17
         22        ASSIGN_DIM                                                   $18, 'price'
         23        OP_DATA                                                      ~20
    5    24    >   INIT_FCALL_BY_NAME                                           'mysqli_fetch_assoc'
         25        SEND_VAR_EX                                                  !2
         26        DO_FCALL                                          0  $21     
         27        ASSIGN                                               ~22     !1, $21
         28      > JMPNZ                                                        ~22, ->2
   19    29    > > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.46 ms | 2142 KiB | 13 Q