Hello, guys I need help, please. I try to make output file with special requirements. With this "csv" files I try to write file.txt. But in my code I don't know how to take another lines from fakt.csv, I can take only the third line, but I need the second and sometimes I have fourth оr fifth lines. I try to put in html field where somebody can make choose if they want number 0000111366 or 1002304974. I try to convert this data in fakt.csv from 2/15/2012 to 15.02.2012 to txt.file. I try to put in html field where somebody can write something like 102/007 and when they write something to put in file.txt between 2/15/2012 and #201 (example: 2/15/2012#102/007#201) fakt.csv ID_PURCHASE_INVOICE,DOC_TYPE_NAME,DOC_EXT_CODE,DOC_NUM,DOC_DATE,WOVAT_AMOUNT,VAT_AMOUNT,TOTAL_AMOUNT,CONTR 108826,fakt,1,0000111366,2/15/2012,160.08,32.02,192.1,prezis,103565237,BG103565237,paris,,,,,,,,,,,,paid,,,,,,,,,, 108830,fakt,1,1002304974,2/15/2012,872.33,174.46,1046.79,ovm,121759222,BG121759222,,,hamburg,,,,,,,,,,paid,,,,,,,,,, delivery_head.csv ID_DOC,DOC_NUM,DOC_DATE,ID_CONTRAGENT,ID_PURCHASE_INVOICE,ID_INVENT,ID_OPERATION,IS_ARCHIVE 1016853,11281,2/16/2012,103000090,108826,10133,1,0 1016858,11286,2/16/2012,103000221,108830,10145,1,0 invent.csv ID_INVENT,INVENT_NAME,ACCOUNT_TAG 10101,101 INCLUSIVEB,3043@@101 10102,102 INCLUSIVEC,3044@@102 10103,1031 INCLUSIVEBV,3044@@1031 contragent.csv ID_CONTRAGENT,CONTRAGENT_NAME,CONTRAGENT_BULSTAT,CONTRAGENT_VATNUMBER,CONTRAGENT_POST_ADDRESS,CONTRAGENT_Z 103000001,conragent,0,0,,,,,,,,,,,, 103000002,BEVERAGESAD,831607255,B831607255,,,paris,,67,,,,,,30, 103000003,amrel,831430207,,,,berlin,,126,,,,,, file.txt OPDDS@@1002304974#2/15/2012#201##987#2/16/2012#fakt######10145@@3044@@102 @@40111@@103000002$BEVERAGESAD$831607255$BG831607255#1002304974#2/15/2012#2/16/2012#872.33#0#0#0#0#0#0@@ $lines = file('fakt.csv'); $lines2 = file('delivery_head.csv'); $lines3 = file('invent.csv'); $lines4 = file('contragent.csv'); $c_lines = count($lines); $c_lines2 = count($lines2); $c_lines3 = count($lines3); $c_lines4 = count($lines4); $i = 1; for($i=1;$i<$c_lines;$i++) { $array1 = explode(",", $lines[$i]); $array2 = explode(",", $lines2[$i]); $array3 = explode(",", $lines3[$i]); $array4 = explode(",", $lines4[$i]); $new_line = "OPDDS@@" . $array1[3] . "#" . $array1[4] . "#201##987" ."#" .$array2[2] ."#" . $array1[1] . "#####" . $array1[11] . "#" . $array2[5] . "@@" . $array3[2]. "@@" . 40111 . "@@" . $array4[0] . "$" . $array4[1] . "$" . $array4[2] . "$" . $array4[3] . "#" . $array1[3] . "#" . $array1[4] . "#" .$array2[2]. "#" .$array1[5] ."#0#0#0#0#0#0@@" ; $data = $new_line . "\n"; } echo nl2br($data); $File = "file.txt"; $Handle = fopen($File, 'w'); $Data = $data; fwrite($Handle, $Data); print "Data Written"; fclose($Handle); PHP: