PHP爆炸函数循环用于列标题,以将所需的值返回到Excel文件中

So I used this code to return an array from a mysql query headers into an Excel file.

while($row_data = mysql_fetch_assoc($result)) {
$row = 1;
if ($col == 1) {
    $row_headings = array_keys($row_data);
    foreach($row_headings as $value) {
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $value);
        $row++;
    }
    $row = 1;
    $col++;

These query headers are returned as values such as 1111X2222X3333. I want to explode these values using this explode function somewhere in there

 list($sid,$gid,$qid) = explode("X", $string);

After this function is used I want to use this query to replace all these column headers with my desired values using this query in the loop

   select * from lime_questions where sid = 1111 and gid = 2222 and qid = 3333

If there is a better way to do this please let me know. I appreciate the help