Quote:
Originally Posted by NY Jester
Kind of new at the php thng, so if create the file rearrange .php using the code above along with the txt file that has the lines I want to change then just access rearrange. php and it will out put on the screen the rearrange strings?
Thanks in advance.
|
Yes.
Or you could output it all to a new txt file by making a few modifcations
PHP Code:
<?php
$contents = file_get_contents("filename.txt");
$line_by_line = explode("\n", $contents);
array_pop($line_by_line); // get rid of the empty line at the end that explode creates
$results = array();
$new_contents = '';
foreach ($line_by_line as $line) {
list ($url, $title, $description) = explode("|", $line);
$new_contents .= "$title|$url|$description\n";
}
$file = fopen("new-filename.txt");
fwrite($file, $new_contents);
fclose($file);
?>