D
D
Danil Sysoev2015-04-24 22:44:13
Programming
Danil Sysoev, 2015-04-24 22:44:13

How to send the first lines of a file to a mailbox?

Guys, hello.
The idea is this: If a file with a contact database. It is necessary that the user presses the button in his personal account, and the first 10 lines from the file are sent to his mail, and then they are deleted. The file will be updated from the bottom. The button is active once a day.
Question: Please direct me where to dig about it? If the script itself is easy, then throw off the basis, I myself will figure it out further.
Thank you for your attention.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Danil Sysoev, 2015-04-25
@YoungOldMan

Thanks a lot for the tip. Here's what happened, in case it's useful to anyone:

$filename= 'file.txt';//путь к файлу
$txt = file($filename);//получаем массив строк
$txt2 = array_slice($txt, 0, 10);//выбираю первые 10 строк
$txt3 = implode('', $txt2);//избавляюсь от лишнего кода
      $mail -> sendMail ($email, $par, $txt3);//класс для отправки сообщений, у каждого разный, в зависимости от того, какой вы используете
      file_put_contents($filename, array_slice($txt, 10));//удаляю первые 10 строк из файла

A
Artem Gribkov, 2015-04-24
@L1Qu0R

Well, in fact, everything is very simple, the question is in what language do you want to implement this? If in php, then just look at working with files, everything is described in detail in the official documentation;)
php.net/manual/en/book.filesystem.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question