I am looking for a programming shortcut. I want to push the entire row into an associative array, the $key being the same as the column name, and the $value being the value in that particular column, and all that, one row at a time.
So far, the only way I know how to do something like this is:
$array = [];
$push_item = [];
while ($row = $result->fetch_assoc())
{
$column_name_1 = $row['column_name_1'];
$column_name_2 = $row['column_name_2'];
//etc.
$push_item = ["column_name_1" => $column_name_1, "column_name_2" => $column_name_2, ];
array_push($array, $push_item);
}
And like that, for every row in the table.
I am looking for a solution that will go easier on my typing. Can I grab the column names and data automatically?
Thank you.