Jump to content

Semicolon in output


geldd001
Go to solution Solved by geldd001,

Recommended Posts

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
Edited by geldd001
Link to comment
Share on other sites

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
Share on other sites

  • Solution

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.