denoteone Posted December 10, 2009 Share Posted December 10, 2009 I have two php pages that communicate with each other by writing data to a text file. one page collects data from the user and on submit the script creates an array and then writes it to a text file. The other page is more of a display page gets the array from the text file and echos the data to the page. one of the tricky parts is that the file that the user updates will be pre-populated with the data from the txt file that way the user knows what the old values are. I understand how to create the array. I jsut need help importing and exporting in and out of the scripts from the php files. Is the array still and array? Or does it become a string? Please any help would be awesome just let me know if you need more info. my array will look something like the following. $price = array("leg_s"=>11.99, "leg_m"=>13.99, "leg_l"=>16.99, "leg_xl"=>17.99); Quote Link to comment https://forums.phpfreaks.com/topic/184667-writing-an-array-into-a-text-file-and-reading-the-array-from-a-text-file/ Share on other sites More sharing options...
wildteen88 Posted December 10, 2009 Share Posted December 10, 2009 If you're wanting to save the array to a text file you'll first want to serialize the array. When you want to re use the array use unserialize However you'll be better of with just using sessions for what you're trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/184667-writing-an-array-into-a-text-file-and-reading-the-array-from-a-text-file/#findComment-974988 Share on other sites More sharing options...
denoteone Posted December 10, 2009 Author Share Posted December 10, 2009 wildteen88 I will try the serialize() method since the data is for a menu board and if the machine that is running the scripts is reset then I lose all data. I will start testing and let everyone know if I run into any problems. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/184667-writing-an-array-into-a-text-file-and-reading-the-array-from-a-text-file/#findComment-974996 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.