I didn't ask the question about this, but I have a related issue. I'm trying to do a replace, and am using str_replace, but the outcome is not what I expected.
Here's my code: <? $fp = fopen("new_data.csv", "r"); $text = fopen("text.txt", "r"); $merged = fopen("merged_text.html", "w"); $filecontents = fread($text,filesize("text.txt")); while ($data = fgetcsv ($fp, 1000, ",")) { $num = count ($data); $fullname = $data[0] . ' ' . $data[1]; $newfullname = '123 ' . $fullname . ' 456'; $filecontents = str_replace($fullname, $newfullname, $filecontents); } fclose ($fp); fwrite($merged,$filecontents); fclose ($merged); fclose ($text); ?> Here's the text file it's working on: John Smith <br> <br> Peter Cooper <br> <br> Mike Brown <br> <br> Lisa Crow <br> Here's the outcome: 123 123 John Smith 456 456 <br> <br> 123 123 Peter Cooper 456 456 <br> <br> 123 123 Mike Brown 456 456 <br> <br> 123 123 Lisa Crow 456 456 <br> I only want it to have one set of 123 and 456 on either side. Any ideas? Josh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php