PHP is a very powerful language, even without the use of a database, but you can only go so far without the need to store and retrieve data. One way to do this is by using flat files.
A flat file is a .txt file used to store information on the server. Because the information is stored in a .txt file, it makes it easy for you to create, manipulate, and delete databases in seconds. There are many methods you can use to store data in flat files, but I've found serialize and unserialize to be the best.
serialize and unserialize are functions in PHP that are handy when you need to store information in flat files. serialize takes an array of data and generates a storable representation of that array. For example:
<?php
|
|
The above code will output the following:
a:3:{i:0;s:4:"some";i:1;s:7:"useless";i:2;s:11:"information";}
If you haven't worked with serialize before, it probably just looks like a bunch of gibberish. However, within that gibberish is the information that was held in the array '$myArray'. See it?
unserialize does the opposite of serialize, it creates an array from a representation(the output of serialize). PHP takes what looks like gibberish above and changes it back into an array, which you can then use as you would a normal array.
Try testing out serialize and unserialize, just to get the hang of how they're used. When you think you have a handle on them, go on to part two.
| Discuss Tutorial: Flat File Databases | 32 Comments |


otherwise I might have never got it done 

Please Can U Help Me. PLZZZZ, i want to make a simple User System with Registration, Login, Edit Profile, Member's List, ForGot PassWord, Remember Me Check BOx and User's Secure Area, Database in a Flat File. Please, and if you can Contact me On MSN Umar_Maqsood@hotmail.com