Topic awaiting preservation: Adding to a 2-Dimensional Array? |
|
---|---|
Author | Thread |
Obsessive-Compulsive (I) Inmate From: Alderaan |
posted 10-06-2004 01:36
I've been learning PHP for a little more then two weeks now. With PHP I found a decent way of organizing my links. As you can see from the code below I created a bunch of arrays (1,2, ...) and then inside them I created an array where I have the link information and catagory. The while loops sorts through my arrays and checks the catagory. If the catagory equals $selection then it prints it out. For my purpose here I just set $selection to something but in the actual use of it I use a form to submit which section I want. code: <?php
|
Nervous Wreck (II) Inmate From: East Anglia, England. |
posted 10-06-2004 10:22
If you want to stay away from mySQL, which would be the best solution, I think a text file would be second best. |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 10-06-2004 10:24
well... I can see serveral ways, the easiest once storing your array into a file, using php->serialise() and php->unserialize() as well as php->fopen() ,php->fwrite() and php->fread() (not to mention php->fclose() ;-) ). |
Paranoid (IV) Inmate From: France |
posted 10-06-2004 11:17
You could even look at the parse_ini_file function. |
Paranoid (IV) Inmate From: Maryland, USA |
posted 10-11-2004 02:04
I did not look too hard at this, so don't be angry if I am irrelevent. code: $myArray[setValue][] where the setValue is the first dimension, and you want to add a new value to the second dimension. |
Nervous Wreck (II) Inmate From: Alderaan |
posted 10-11-2004 22:59
Thanks for all the help guys. |
Nervous Wreck (II) Inmate From: Alderaan |
posted 10-12-2004 01:14
Could you explain the serialize function a bit more TP? I attempted to simply open, read, and close a seperate text file like I would in C++ but that doesn't appear to work the way I planned. I'll post what I'm working with though: code: <?php
|
Paranoid (IV) Inmate From: Maryland, USA |
posted 10-13-2004 00:18
The problem is that in your while loop you have the incorrect number of parentheses. It should be: code: while($counter1 < sizeof($number))
|