$ firstbloodkill陣列:使空數組值設置爲0
Array ([0] => [1] => [2] => [3] => [4] => [5] => 1 [6] => [7] => [8] => [9] =>)
我想空值設置爲0。
什麼我嘗試做:
Array ([0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 1 [6] => 0 [7] => 0 [8] => 0 [9] => 0)
我代碼:
foreach ($firstbloodkill as $key => $element)
{
if($element == "")
{
$firstbloodkill[$key] = 0;
}
}
它不工作。我做錯了什麼?
編輯:我發現我做錯了什麼。陣列名稱是'firstBloodKill'。我將firstbloodkill改爲firstBloodKill並開始工作。對不起,我很笨。
檢查你有什麼是價值:'的var_dump($元素) ;' – nospor