Is this OK ?
$i = 0; while ($row = mysql_fetch_array($result)) { $resultset[] = $row; $columns[] = mysql_fetch_field($result, $i); }
Though it's deprecated and no longer in PHP 7 you can avoid having to use an object by using the function mysql_field_name instead which returns a string.
mysql_field_name