I have the following code to push data into an array if a condition is true however the result is not what I was hoping for;
<?php
$sql = "SELECT * FROM cart WHERE sess_id = '$sess_id'";
$result = mysqli_query($conn, $sql);
$items= array();
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result))
{
$items[] = [
'sku' => $row["prod_sku"],
'quantity' => (int)$row["prod_qty"]
];
}
if ($postage === 4.00){
array_push($items, "sku_GSxe2lDNfK5b6E", 1);
}
}
$conn->close();
?>
I would like the second record to look the same as the first, excluding the record information. Can someone please tell me how do go about it. I have not done a lot with arrays and I cant find the information I need anywhere. Thanks in advannce.
[{"sku":"sku_GGBzZqwz44UhRf","quantity":1},"sku_GSxe2lDNfK5b6E",1]
I want it to output like this
[{"sku":"sku_GGBzZqwz44UhRf","quantity":1}, {"sku":"sku_GSxe2lDNfK5b6E","quantity":1},]