I'm not the best at PHP and would be extremely grateful if somebody could help. Basically I need to parse each line of a datafeed and just get each bit of information between each "|" - then I can add it to a database. I think I can handle getting the information from between the "|"'s by using explode but I need a bit of help with parsing each line from a text file as a singular. Infact to make it even more simple, I just need it to use each line of a variable, I will submit content to the variable using a textarea and a form. Any help would be greatly appreciated!
You can read a file into an array of lines and do all the splitting with:
$lines = file("filename");
foreach($lines as $line) {
$parts = explode("|", $line);
// do the database inserts here
}
If you already have all the text in a variable as you said (e.g., with something like file_get_contents() ), you can explode on \n first and then do the same foreach statement as above.