How to add a value before each line in a txt file?

Discussion in 'Programming' started by topgun1111, Jan 28, 2012.

  1. #1
    Hi I have a txt file and 15 000 youtube codes per line like HqiHRC4Q_Ac in it.I want to add "http://www.youtube.com/watch?v=" and create full youtube urls from this codes.

    How can I do it ?

    I have : video codes

    ekJbxA6JOAU
    AJWjZ-dOKgI


    I want to create full urls like http://www.youtube.com/watch?v=ekJbxA6JOAU

    Thanks
     
    topgun1111, Jan 28, 2012 IP
  2. topgun1111

    topgun1111 Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    please help me !
     
    topgun1111, Jan 28, 2012 IP
  3. mmerlinn

    mmerlinn Prominent Member

    Messages:
    3,197
    Likes Received:
    819
    Best Answers:
    7
    Trophy Points:
    320
    #3
    Dump your youtube codes text file into a database with a FIELD NAME of "dummy" where the size of the FIELD NAME is long enough for your longest URL then do this:

    REPLACE dummy WITH "http://www.youtube.com/watch?v=" + dummy ALL

    Then dump your database back to a text file.
     
    mmerlinn, Jan 28, 2012 IP
  4. dany3l89

    dany3l89 Active Member

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    96
    #4
    $url = "http://www.youtube.com/watch?v=";
    $file = "youtube.txt";
    $f = fopen($file, "r");
    while($line = fgets($f, 1000)){
    $full_path = $url.$line;
    echo $full_path."<br/>";
    }
     
    dany3l89, Jan 29, 2012 IP
  5. topgun1111

    topgun1111 Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks for the answers, I did it
     
    topgun1111, Jan 30, 2012 IP