将一行文本分解为多个变量和一个数组

Explode a line of text to multiple variables and an array

我正试图在 php 中爆出一行文本。这样,一行包含
"[姓名]","[状态]",[性别]","[date_of_birth]","[年龄]","[testing_date]"," [answer_for_Test_V_nos._1_to_168]","[SAI_Raw_Score]","[RPM_Raw_Score]","[English_Raw_Score]", "[Math_Test_I_Raw_Score]","[Math_Test_II_Raw_Score]","[Total_Score]"

粗体(总共有 169 个数据)是我要存储在数组中的数据。

这是示例行:

"DELACRUZ JUAN H","F","M","101887","18","030105","3","0","1","2","3","3","0","2","1","0","2","1","1","3","3","3","1","2","3","3","2","1","1","2","1","2","1","3","1","0","1","3","0","2","1","0","1","3","1","1","1","1","0","2","1","1","1","2","0","3","0","3","3","1","0","2","3","3","0","2","0","2","0","0","1","2","3","3","1","2","1","3","2","2","0","3","2","2","1","1","0","0","2","3","2","0","0","2","3","3","0","1","0","3","0","1","1","3","2","0","3","1","1","0","1","2","1","0","1","3","2","0","3","0","2","2","2","2","1","1","0","3","3","3","2","3","2","1","2","3","2","1","2","0","0","1","1","2","0","0","2","3","1","2","2","3","3","1","0","0","0","0","3","2","2","1","1","3","1","1","0","2","0","2","2","1","3","2","060","055","083","015","042","0255"

这里是爆炸的代码,但是这里的数组不起作用:

list($name, $status, $gender, $bday, $age, $date, $answers[169], $SAI, $RPM, $english, $math1, $math2, $total) = explode(",", $line);

请帮忙,如何使用 "list() = explode()" 将这 169 个值分解为数组的每个索引?或者除了使用 list() = explode() 之外还有其他方法吗?

只需使用 array_splice.

提取您需要的值
$line = '"DELACRUZ JUAN H","F","M","101887","18","030105","3","0","1","2","3","3","0","2","1","0","2","1","1","3","3","3","1","2","3","3","2","1","1","2","1","2","1","3","1","0","1","3","0","2","1","0","1","3","1","1","1","1","0","2","1","1","1","2","0","3","0","3","3","1","0","2","3","3","0","2","0","2","0","0","1","2","3","3","1","2","1","3","2","2","0","3","2","2","1","1","0","0","2","3","2","0","0","2","3","3","0","1","0","3","0","1","1","3","2","0","3","1","1","0","1","2","1","0","1","3","2","0","3","0","2","2","2","2","1","1","0","3","3","3","2","3","2","1","2","3","2","1","2","0","0","1","1","2","0","0","2","3","1","2","2","3","3","1","0","0","0","0","3","2","2","1","1","3","1","1","0","2","0","2","2","1","3","2","060","055","083","015","042","0255"';
$splitArray =  explode(",", $line);
$testAnswers = array_splice($splitArray, 6, 168); //Extract the values that you need. Leave the rest as they are.
list($name, $status, $gender, $bday, $age, $date, $SAI, $RPM, $english, $math1, $math2, $total) = $splitArray; //Put the remaining into the variables as required
var_dump($testAnswers); //All the answers
var_dump($name); //The name