0

After sending the string via the email i want to save it into file. so i do it this way:

file_put_contents("coupon.txt", $email.  $RandomString  , FILE_APPEND | LOCK_EX);

and in this way it's look like this:

email@email.com12d45f8e9email2@email2.com1d2d5s4d51d

so no new line and no space between the codes. when i tray to use this way:

file_put_contents("coupon.txt", $email. .  $RandomString .PHP_EOL.  , FILE_APPEND | LOCK_EX);

it's just wont save anything, more then this is to error the mail sending.

Tal.

praiA Tent
  • 17
  • 4
  • typo ! `$email. .` won't work try `$email .` and `PHP_EOL.` won't work either, remove this final dot. – Kaiido Aug 27 '15 at 09:35

2 Answers2

1

use \t and \n in the string you want to write.

file_put_contents("coupon.txt", $email."\t". $RandomString . "\n" , FILE_APPEND | LOCK_EX);

Yang
  • 754
  • 2
  • 8
  • 22
0

You need to append "\n", try this:

file_put_contents("coupon.txt", $email . "  " . $RandomString . "\n"  , FILE_APPEND | LOCK_EX);
huwence
  • 326
  • 1
  • 8