mam problem z generowaniem pliku CSV z odpowiednim kodowaniem. Wczytuje plik XML(UTF-8) i na jego podstawie generuje plik CSV, który jest mi potrzebny. Problem w tym, że CSV musi być w kodowaniu ANSI(Windows-1252).
Próbowałem osiągnąć ten efekt funkcją iconv jednak niestety pojawia się informacja "Notice: iconv(): Detected an illegal character in input string".
$local_file = $_FILES["fileToUpload"]["tmp_name"]; $xml=simplexml_load_file($local_file); array('Nr', 'Tytuł', 'Kontrahent', 'Cena', 'Ilość', 'Wartość', 'Data transakcji', '[k_email]', '[k_adres]', '[k_imie]', '[k_kod]', '[k_miasto]', '[k_nazwisko]', '[k_nick]', '[k_nr]', '[k_firma]', '[k_tel]', '[aukcja_cena_sztuki]', '[aukcja_data]', '[aukcja_nazwa]', '[aukcja_sztuk]') ); function encodeCSV(&$value, $key){ $value = iconv('UTF-8', 'Windows-1251', $value); } foreach ($xml->transaction as $element) { $orderID=$element->OrderId; $itemName=$element->Name; $customerLogin=$element->CustomerLogin; $itemPrice=$element->positions->position->Price; $itemQuantity=$element->positions->position->Quantity; $orderTotal=$element->Total; $orderDate=$element->SellDate; $customerEmail=$element->CustomerEmail; $customerAddress=$element->CustomerAddress; $customerName=$element->CustomerName; $customerName = $customerNameArray[0]; $customerZip=$element->CustomerZip; $customerCity=$element->CustomerCity; $customerSurname=$customerNameArray[1]; $customerId=""; $customerCompany=$element->InvoiceCompanyName; $customerPhone=$element->CustomerPhone; $itemadd = array($orderID, $itemName, $customerLogin, $itemPrice.' zł', $itemQuantity, $orderTotal.' zł', $orderDate, $customerEmail, $customerAddress, $customerName, $customerZip, $customerCity, $customerSurname, $customerLogin, $customerId, $customerCompany, $customerPhone, $itemPrice.' zł', $orderDate, $itemName, $itemQuantity); } foreach ($list as $fields) { fputcsv($fp, $fields, $delimiter = ';'); } $file="plik.csv"; exit; }