savagenoob Posted May 9, 2010 Share Posted May 9, 2010 I dont have much experience in parsing but need to parse a txt file of its contents to put the data into my database. The data looks like.... "0","0","0","0028557" "1","37","1","Bob Jones","1234 Road St","Lala Land","91111","34","Lala Land","35","(916) 111-1111","1","1","CA - FSC RATER","05/09/2010","20","35","Workplace","1234 Blah Way Sacramento CA 91111","(916) 111-1111","","1234 lala Way","Sacramento","91111","1","677","Radio","","1","1","0","0","0.00","0.00","0","0","0","05/09/2010","I","","73","0","0","0","Bob","Jones","Blah Insurance Co.","1165.25","05/09/2010","A","0","1234 Road Way","Sacramento","CA","91111","0.00","CA","73","1163.00","2.25","0.00","05/09/2010","Auto","","Blah RSVP","0","0.00","0.00","0.00","05/09/2010","","","","0","0.00","0.00","0.00","05/09/2010","","","","0","0.00","0.00","0.00","05/09/2010","","","","0","0.00","0.00","0.00","05/09/2010","","","","0","0.00","0.00","0.00","05/09/2010","","","","0","0.00","0.00","0.00","05/09/2010","","","","0","0.00","0.00","0.00","05/09/2010","","","","0","0.00","0.00","0.00","05/09/2010","","","","0","0.00","0.00","0.00","05/09/2010","","","","0","0.00","0.00","0.00","05/09/2010","","","","0","0.00","0.00","0.00","05/09/2010","","","","0","0.00","0.00","0.00","05/09/2010","","","","","111111111","","","0","0","0","","[email protected]","Bizzzzz","" and I need to put the useful data in between each "" into a variable. Any pointers, tips, suggestions, examples? Thanks Link to comment https://forums.phpfreaks.com/topic/201200-txt-file-parsing-help/ Share on other sites More sharing options...
teamatomic Posted May 9, 2010 Share Posted May 9, 2010 $string=file_get_contents("./your_file.txt"); $string=str_replace('"','',$string); list($var1,$var2,$var3,etc)=explode(",",$string); HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/201200-txt-file-parsing-help/#findComment-1055576 Share on other sites More sharing options...
savagenoob Posted May 10, 2010 Author Share Posted May 10, 2010 OK, that works for the first part, but without me creating like 1000 variables to get the data I need, is there a way to skip to a certain place of , after I explode the data? The name, address and so on will be at the same count of commas every time so i wanna skip all the data I dont need, not sure how to do it. Thanks a million for your help. Link to comment https://forums.phpfreaks.com/topic/201200-txt-file-parsing-help/#findComment-1055582 Share on other sites More sharing options...
teamatomic Posted May 10, 2010 Share Posted May 10, 2010 After the str_replace use implode to get the contnets into an array then just count to what you want. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/201200-txt-file-parsing-help/#findComment-1055599 Share on other sites More sharing options...
savagenoob Posted May 10, 2010 Author Share Posted May 10, 2010 Duh, I got it, just make it an array instead of a list and just point to that array number... noob i am. thanks. Doh, you answered as I responded lol Link to comment https://forums.phpfreaks.com/topic/201200-txt-file-parsing-help/#findComment-1055600 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.