View Single Post
Old 2009-02-13, 02:40 PM   #2
Beaver Bob
Porn Blog Addict
 
Beaver Bob's Avatar
 
Join Date: Oct 2005
Location: Las Vegas, Nevada
Posts: 715
Send a message via ICQ to Beaver Bob
Quote:
Originally Posted by NY Jester View Post
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);
?>
Beaver Bob is offline   Reply With Quote