denoteone Posted November 3, 2009 Share Posted November 3, 2009 Is it possible to import a set of variables from a .txt file that is created by a java api? I need to create a php page wrapped around a java app that uses an api to collect data and it stores the data in an file. I then need to use those variables in my php script. If anyone can point me in the right direction I would greatly appreciate it. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/180178-import-variables-from-external-file/ Share on other sites More sharing options...
mikesta707 Posted November 3, 2009 Share Posted November 3, 2009 what does the text file look like? just a bunch of strings? Quote Link to comment https://forums.phpfreaks.com/topic/180178-import-variables-from-external-file/#findComment-950473 Share on other sites More sharing options...
denoteone Posted November 3, 2009 Author Share Posted November 3, 2009 initially we were talking about a XML file but it can be in any format from my understanding. Quote Link to comment https://forums.phpfreaks.com/topic/180178-import-variables-from-external-file/#findComment-950475 Share on other sites More sharing options...
mikesta707 Posted November 3, 2009 Share Posted November 3, 2009 try checking out the PHP xml parser if its XML. for other formats, you will have to do different things, so what other formats might there be? Quote Link to comment https://forums.phpfreaks.com/topic/180178-import-variables-from-external-file/#findComment-950478 Share on other sites More sharing options...
denoteone Posted November 3, 2009 Author Share Posted November 3, 2009 The only other format would be a .txt file with a variable name and what it equals then a break and so on. Quote Link to comment https://forums.phpfreaks.com/topic/180178-import-variables-from-external-file/#findComment-950487 Share on other sites More sharing options...
mikesta707 Posted November 3, 2009 Share Posted November 3, 2009 oh so the text file would look like var1 = valu1 var2 = val2 etc.. if the value is a string, is it surrounded by quotes? theoretically, if the txt files are good, you could just append a $ symbol at the beginning, and add a semi colon at the end, and use EVAL, though depending on the source of the file, this could be dangerous. Can you give a very specific example of a test file Quote Link to comment https://forums.phpfreaks.com/topic/180178-import-variables-from-external-file/#findComment-950490 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.