Ce code permet de créer un nouveau fichier .txt. Si le fichier n'existe pas encore, il créera le fichier.Rechercher un fichier et migrer le terme de recherche dans un nouveau fichier
<?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);
?>
Et ce code identifie ici chaque ligne de chaîne dans un jeton.
<?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");
}
?>
Le people.txt ressemble à ceci
John Smith
John Meyer
John Chase
John Smith //i want to transfer this set of string into a new file
Qu'est-ce que je manque ici?
Quelle est votre question? –
Je veux transférer un ensemble de chaîne dans un fichier différent, en identifiant d'abord la première et la dernière chaîne. – woninana