Results 1 to 2 of 2

Thread: PHP help needed PLZ!

  1. #1
    Join Date
    Feb 2009
    Posts
    62
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default PHP help needed PLZ!

    Ok so I have several functions I have been working all morning to combine.

    First to combine my old list with a the new list.
    PHP Code:
    $old_list 'top100.txt';
    $new_list file_get_contents('http://kywordpro.com/top100print.php');
    file_put_contents($old_list$new_listFILE_APPEND LOCK_EX); 
    Second I want to replace a few items from the updated list
    PHP Code:
    $updated_list 'top100.txt';
    $search = array(' ');
    $replace = array('+');
    $subject $updated_list;
    $newlyupdated_list str_replace($search$replace$subject); 
    Then I want to organize my newly updated list

    PHP Code:
    $list $newlyupdated_list
    $list array_map("strtolower"$list); 
    $list array_unique($list); 
    sort($listSORT_STRING); 
    file_put_contents('perfect_list.txt'implode(''$list)); 
    Can anyone help me get this to work properly?

    Tim..
    Last edited by tgallagher26; 04-10-2009 at 12:17 PM.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Well, you can make one files for past lists, and one file for the current list. Replace:
    PHP Code:
    <?php
    $old_list 
    'top100.txt'
    $new_list file_get_contents('http://kywordpro.com/top100print.php'); 
    file_put_contents($old_list$new_listFILE_APPEND LOCK_EX);  
    ?>
    With:
    PHP Code:
    <?php 
    $target_file 
    'top100.txt';
    $all_data "past100.txt";
    $all_data_file trim(file_get_contents($all_data)."\n".file_get_contents($target_file));
    $split explode("\n"$all_data_file);
    $split array_unique($split);
    sort($split);

    $file fopen($all_data'w');
    fwrite($filetrim(implode("\n"$split)));
    fclose($file);

    $file fopen($target_file'w');
    fwrite($filetrim(file_get_contents('http://kywordpro.com/top100print.php')));
    fclose($file);
    ?>
    Last edited by Nile; 04-08-2009 at 08:09 PM. Reason: bad code
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    tgallagher26 (04-10-2009)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •