Этот код позволяет создать новый файл .txt, если файл еще не существует, он создаст файл.
<?php
$file = 'people.txt';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
$current .= "John Smith\n";
// Write the contents back to the file
file_put_contents($file, $current);
?>
И этот код здесь идентифицирует каждую строку строки в токене.
<?php
$string = "This is\tan example\nstring";
/* Use tab and newline as tokenizing characters as well */
$tok = strtok($string, " \n\t");
while ($tok !== false) {
echo "Word=$tok<br />";
$tok = strtok(" \n\t");
}
?>
People.txt выглядит так
John Smith
John Meyer
John Chase
John Smith //i want to transfer this set of string into a new file
Чего мне здесь не хватает?