我有一个从 csv 导入的数组。但是 csv 的最后一行是 epmty,但它仍然将空值导入到数组中。
有没有一种简单的方法来检查数组中的整行是否为空?
这是我正在使用的代码(我正在根据另一个数组的内容检查该数组以构建一个 mySQL 语句:
foreach (array_keys($array[0]) as $arraykey => $dbtitles){
foreach ($fields as $dbkey => $dbfield){
if ($dbtitles == $dbfield && !empty($arraykey) ){
$insertSQL .= "student_" . $dbkey . ", ";
}
}
}
抱歉,如果我是愚蠢的。
这是我的数组的最后一部分:
[21] => Array
(
[Username] =>
[Last_Name] => Jones
[First_Name] => Tom
[Email] =>
[Password] => password
[Student_Id] =>
[Middle_Name] =>
[Job_Title] =>
[Department] =>
[Company] =>
[Street_1] => 21 A Road
[Street_2] =>
[City] => Exeter
[County] =>
[Postcode] => EX1 1AA
[Country] =>
[Work_Phone] =>
[Home_Phone] =>
[Work_Fax] =>
[Mobile_Phone] => 07111 222333
[Website] =>
[Role] => Exeter City
)
[22] => Array
(
[Username] =>
[Last_Name] =>
[First_Name] =>
[Email] =>
[Password] =>
[Student_Id] =>
[Middle_Name] =>
[Job_Title] =>
[Department] =>
[Company] =>
[Street_1] =>
[Street_2] =>
[City] =>
[County] =>
[Postcode] =>
[Country] =>
[Work_Phone] =>
[Home_Phone] =>
[Work_Fax] =>
[Mobile_Phone] =>
[Website] =>
[Role] =>
)