Search and Replace within a Text file using mySQL queries
How can I create PHP to search the testing.txt file for each name in the database table and replace the name with the database table id?
So that the text file looks like this:
3 | 1 | 4 | 5
2 | 3 | 6
4 | 5 | 2
and so forth an so on...
I have a mysql table called "nameslist" that looks like this:
---------------------
id | name
---------------------
1 | bob
2 | john
3 | tom
a开发者_StackOverflownd so forth an so on...
I have a text file called "testing.txt" that looks like this:
tom | bob | mary | paul
john | tom | rachel
mary | paul | john
and so forth an so on...
Welcome to SO. Nice number you've got!
Though, your question not that clear. What's the certain problem? An algorithm?
The easiest way is to read both file and table into arrays and then run a loop other data, replacing names with numbers.
Then write a file over.
精彩评论