Today I won’t write many letters, I’ll show a simple code that allows to sort file contents by alphabet.
<?
// Getting file into array
$stroki=file(”unsorted.txt”);
//Sorting it without keys - we don’t need them
sort($stroki);
// Writing sorted strings to a new file
$fs=fopen(”./sorted.txt”, “a”);
foreach ($stroki as $string)
{
fwrite($fs, trim($string).”\r\n”);
}
fclose ($fs);
echo “Completed”;
?>
addthis_url = ‘http%3A%2F%2Fwww.lampdocs.com%2Fblog%2F2008%2F05%2F28%2Feasiest-way-to-sort-strings-from-a-file-by-alphabet-with-php%2F’;
addthis_title [...]