I decided to make a TV program cleaner. The cleaner will have two modes: the first is the loading and processing of text files (there may be up to 30, but the names do not change), the second is when you copy the text of one file, insert it into <textarea> and get the result. For the first mode, almost everything is ready and it seems to be working for now. I made a class and registered variables:
public $fileName, $startTime, $endTime, $findAndDelete; public function Raw(){...} public function Del($array){...} Here are indicated, respectively:
the name of the file to be processed, the start time of the TV program, the time of its end (the rest of the time is deleted or transferred to the next day). Raw() reads files line by line using file() to return to normal appearance and return an array. Del() removes all unnecessary in accordance with $findAndDelete from the resulting array Raw() and returns the processed array.
For example, for a discovery channel would look like this:
$disc_eu_s = new Channel; $disc_eu_s->fileName = 'disc_eu_s.txt'; $disc_eu_s->startTime = '10:00'; $disc_eu_s->endTime = '02:00'; $disc_eu_s->findAndDelete = array( '~с Беаром Гриллсом~u', '~с Эдом Стаффордом~u' ); result( $disc_eu_s->del( $disc_eu_s->raw() ) ); So the question is.
How to correctly “tie” the class to the second mode so that both modes process the text equally regardless of whether I uploaded it as a file or opened the file and copied and pasted the text?
In the first mode, files are read line by line and in the second mode, the inserted text will also be read line by line explode("\n", ...) . The only thing I did in vain was to set up the public $fileName , which is useless for the second mode. By the way, here’s something else in common for both modes (which can help in my question) - this is the first line in the file and the first line in the inserted text - the name of the channel is indicated here, but how to tie it up correctly?
Ps I forgot to mark one important point in my question. Processing in the first mode occurs according to the plan, that is, if the file is disc_eu_s.txt, then the start and end times, as well as findAndDelete, are appropriate for it. And if I open the same file, copy the content and paste it into the textArea, then the application (if it can be said so) must recognize that it is text as from disc_eu_s.txt and is edited according to its variables. Therefore, I wanted to become attached to the first line with the name of the channel ...