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"]; } } ?>
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught Error: Call to undefined function mysqli_fetch_assoc() in /in/6NfOm:5 Stack trace: #0 {main} thrown in /in/6NfOm on line 5
Process exited with code 255.

preferences:
101.12 ms | 1526 KiB | 4 Q