Я пытаюсь обрабатывать файл CSV через php, и у меня он работает. Но есть один массив, который мне нужно изменить на основе набора условий.if elseif indie while loop
$file_handle = fopen($path, "r");
while (!feof($file_handle)) {
$line_of_text = fgetcsv($file_handle, 100000);
if($currency == "US"){
$line_of_text[6] = str_replace ("if_you_find_this","change_to_this",$line_of_text[6]);
$line_of_text[6] = str_replace ("if_you_find_this","change_to_this",$line_of_text[6]);
} elseif($currency == "DE"){
$line_of_text[6] = str_replace ("if_you_find_this","change_to_this",$line_of_text[6]);
$line_of_text[6] = str_replace ("if_you_find_this","change_to_this",$line_of_text[6]);
}else {
echo "Something with currency handling went wrong. Please contact support.";
}
$data .= $line_of_text[0] . "," . $line_of_text[1] . "," . $line_of_text[2] . "," . $line_of_text[4] . "," . $line_of_text[6] . "," . $line_of_text[49] . "," . $line_of_text[51] . "\n";
}
fclose($file_handle);
$new_file_handle = fopen($path, "w");
fwrite($new_file_handle, $data);
Это не ошибка, но кажется, что весь условный блок игнорируется. Помогите?
забыли вставить важную строку, которая уже находится в рабочем файле -> $ line_of_text = fgetcsv ($ file_handle, 100000); – jeffimperial