tommytx Posted January 4, 2018 Share Posted January 4, 2018 I am trying to capture some data on the fly that is marked to be inserted in the db.. but its a huge dump and is very slow getting it into the db.but i can download the entire package and save it in text in less than 3 minutes.. so the idea is to capture it on the fly and then once off line move the data to the db.. should save hours of time and not tie up the MLS server so long.. So here is what i need.. Want to capture it on the fly which i can do.. but the question is how do i save it to txtfile so that it can easily be reloaded as an arrray in the future. I can break it apart any way i like and add ticks or quotes or anything and save the pieces.. but surely there is a very efficient way to do if for multi array... as i think its important how its stored if say i winat to pull the arrays quickly from file usging something like$str = file('mytextfile.txt'); Hope all this makes sense.. what follows is an example of sample code that i am experimenting with to see how to work this.. any thoughts or suggestions would be appreciated. $contacts = [['name'=>'S Russell','email'=>'s.russell@vahud.com','title'=>'President'], ['name'=>'D Randall','email'=>'d.Randall@vahud.com','title'=>''], ['name'=>'T Joneses','email'=>'t.joneses@vahud.com','title'=>'Professor'], ['name'=>'A Soloing','email'=>'a.soloing@vahud.com']]; Array ( [0] => Array ( [name] => S Russell [email] => s.russell@vahud.com [title] => President ) [1] => Array ( [name] => D Randall [email] => d.Randall@vahud.com [title] => ) [2] => Array ( [name] => T Jones [email] => t.jones@vahud.com [title] => Professor ) [3] => Array ( [name] => A Solo [email] => a.solo@vahud.com ) ) So how should the code be broken apart and placed in saving.. to easily be reloaded quickly exactly like the array it was since it will be fed back to the same program that it was taken from in midstream. Quote Link to comment Share on other sites More sharing options...
requinix Posted January 4, 2018 Share Posted January 4, 2018 Ever heard of JSON? Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted January 4, 2018 Solution Share Posted January 4, 2018 You could use json_encode then save it to a text file. Then use json_decode after reading it back to recreate the array. Quote Link to comment Share on other sites More sharing options...
tommytx Posted January 4, 2018 Author Share Posted January 4, 2018 Thanks will go study json and see if i can figrue it out was going thru all kinks of gyrations but nothing worked.. will come back after i assemble a few hundred json samples.. Quote Link to comment Share on other sites More sharing options...
tommytx Posted January 4, 2018 Author Share Posted January 4, 2018 Thanks that worked perfect.. save it and retrieved it in the exact same state it was in originally... you guys are great.. Maddening you told me where fish and that helped but SEN threw me a couple of fish to get started and speeded up my process significantly as i would have had no idea where to start as i have never used json before.. so he wins.. but i really do appreciate the quick response from both of you.. This is one forum that yu always know you wont need to wait days for help.... Thanks agai. Quote Link to comment Share on other sites More sharing options...
Barand Posted January 4, 2018 Share Posted January 4, 2018 Do you see where your name is at the top of your posts? It doesn't say much for your abilities that you can't work out that our names are the same place in our posts as your name is in yours. Quote Link to comment 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.