ttocskcaj Posted May 24, 2011 Share Posted May 24, 2011 I have a local text file with several lines of json data. (Each line is different). Is there any way to load this file into a var? That way I can decode each set of json like var[0], var[1] etc. The json data in the text file is updated every minute by a python script. Quote Link to comment https://forums.phpfreaks.com/topic/237314-load-file-to-array-1-line-per-value/ Share on other sites More sharing options...
Adam Posted May 24, 2011 Share Posted May 24, 2011 Are you wanting to do this as the page loads, or when an event is triggered? Quote Link to comment https://forums.phpfreaks.com/topic/237314-load-file-to-array-1-line-per-value/#findComment-1219635 Share on other sites More sharing options...
Zane Posted May 24, 2011 Share Posted May 24, 2011 glob does exactly this. Quote Link to comment https://forums.phpfreaks.com/topic/237314-load-file-to-array-1-line-per-value/#findComment-1219704 Share on other sites More sharing options...
ttocskcaj Posted May 25, 2011 Author Share Posted May 25, 2011 Zanus, I want to do it in javascript. That's a php function. Unless there is a way to pass a php variable to javascript? I guess I could load it with php, and put it in a hidden div? I'm using jquery, so it's just part of the document ready function. The JSON in the file contains a list of online players in a server, and this list is shown in a hover box. Quote Link to comment https://forums.phpfreaks.com/topic/237314-load-file-to-array-1-line-per-value/#findComment-1219888 Share on other sites More sharing options...
Adam Posted May 25, 2011 Share Posted May 25, 2011 Just use jQuery.ajax to load the file -- be sure in your case to turn off caching. Quote Link to comment https://forums.phpfreaks.com/topic/237314-load-file-to-array-1-line-per-value/#findComment-1219898 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.