Forum Moderators: coopster
Now, I'm trying to pass value of postal code and this script should return me value of coresponding email. I have around 700,000 postal codes (yep a lot) and I cannot use database or any plugins for PHP which needs to be installed. It takes about 30 seconds to find that email. I tried usin FFDB [sourceforge.net...] but I don't know what type of file should I use. When I create new database with FFDB it gives me this file which has square symbols in there and a lot of spaces. //Here is how it looks like:/*# teterine anton 316205% teterina natalia 382858# machinsky iana 317494*/
It could be just me :-)
If anybody knows a way around this problem please let me know, and guys please keep in mind that I'm not that professional in PHP.
Thanks in advance.
Does the Canadian postal code system map nicely to a hierarchical structure?
If so, you could use the filing system on your disk (assuming that you have mkdir permissions) to create yourself an index tree.
For example, the email address for postcode A1A1A1 you would store in the file (for example):
/postcodedb/A1/A1/A1A1A1.txt
also in that directory might be:
/postcodedb/A1/A1/A1A1A2.txt
and
/postcodedb/A1/A1/A1A1A3.txt
wheras the email address for postcode A1A2A1.txt would be in the file:
/postcodedb/A1/A2/A1A2A1.txt
You get the idea.
A lookup is then performed by simply doing an fopen() on the appropriate filename, which you can derive from the postcode you are trying to lookup.
It will certainly be extremely fast.
But it'll be fast once you're all setup.
If you need info on how to create file / directory, check the File System [php.net] functions in the manual.
mavherick