geldd001 Posted May 26, 2013 Share Posted May 26, 2013 Hello, As en newbie in php i am looking to a solution for the creation of an output file with semicolon seperations in it. comma delimitied is no option because the file contains values with a comma. $myFile = "data.txt"; $data1 = "".$text1.",".$text2.",".$text3.PHP_EOL; $data2 = "".$text4.",".$text5.",".$text6; $fp = fopen($myFile, 'w') or die('Could not open file!'); fwrite($fp, "$data1"."$data2") or die('Could not write to file'); fclose($fp); The result is: test1,test2,test3 test4,test5,test6 I Would like to have: test1;test2;test3 test4;test5;test6 Thanks in advance Link to comment https://forums.phpfreaks.com/topic/278397-semicolon-in-output/ Share on other sites More sharing options...
requinix Posted May 26, 2013 Share Posted May 26, 2013 ... Have you even tried to solve this yourself? I don't understand how you cannot see the answer. Link to comment https://forums.phpfreaks.com/topic/278397-semicolon-in-output/#findComment-1432344 Share on other sites More sharing options...
geldd001 Posted May 26, 2013 Author Share Posted May 26, 2013 Yes I tried. As I mentioned I am a newbie and no guru. One off the value has a vlaue with a comma in it. This is not in my sample. If you just change all the , for a ; than it ends up with more data fields. If the solution is that simple. Please tell. Link to comment https://forums.phpfreaks.com/topic/278397-semicolon-in-output/#findComment-1432345 Share on other sites More sharing options...
xenLiam Posted May 26, 2013 Share Posted May 26, 2013 ... You change "," to ";" in $data1 and $data2. Link to comment https://forums.phpfreaks.com/topic/278397-semicolon-in-output/#findComment-1432346 Share on other sites More sharing options...
geldd001 Posted May 26, 2013 Author Share Posted May 26, 2013 Solved! I tried that first but probably I made a mistake somewhere: Changed: $data1 = "".$text1.",".$text2.",".$text3.PHP_EOL; $data2 = "".$text4.",".$text5.",".$text6; In: $data1 = "".$text1.";".$text2.";".$text3.PHP_EOL; $data2 = "".$text4.";".$text5.";".$text6; Thanks for support Link to comment https://forums.phpfreaks.com/topic/278397-semicolon-in-output/#findComment-1432358 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.