[SOLVED] Advanced associative arrays
Posted: Wed Feb 02, 2005 8:25 am
Ok, I've got this table of items that are used throughout my current program. Currently, they are used from several different arrays and I want to combine it into an array of associative arrays and just have one array I reference. Here's what I'm using so far:
Here's what I've got so far (which obviously isn't quite what I want). But it will be the array to end all arrays!
What I want to be able to do is specify something like or call the array this way
Any ideas on how to set this up? The big picture is that each item represents a category and its corresponding spot in a MySQL database along with a few other attributes. I'm trying to keep my programming as dynamic as possible so that if we want to add a category later on, we add a line in the array in one file and it works globally.
Thanks,
Paul
Code: Select all
$filenameї'Quality'] = "./files/quality.txt";
$filenameї'Ending'] = "./files/ending.txt";
$filenameї'So_Ugly'] = "./files/ugly.txt";
$filenameї'So_Fat'] = "./files/fat.txt";
$filenameї'So_Dumb'] = "./files/dumb.txt";
$filenameї'Looked_Like'] = "./files/looked_like.txt";
$filenameї'Misc'] = "./files/misc.txt";
$DB_tableї'Quality'] = "adjective";
$DB_tableї'Ending'] = "end_phrase";
$DB_tableї'So_Ugly'] = "phrase";
$DB_tableї'So_Fat'] = "phrase";
$DB_tableї'So_Dumb'] = "phrase";
$DB_tableї'Looked_Like'] = "phrase";
$DB_tableї'Misc'] = "phrase";
$typeї'Quality'] = $_POSTї'Quality'];
$typeї'Ending'] = $_POSTї'Ending'];
$typeї'So_Ugly'] = $_POSTї'So_Ugly'];
$typeї'So_Fat'] = $_POSTї'So_Fat'];
$typeї'So_Dumb'] = $_POSTї'So_Dumb'];
$typeї'Looked_Like'] = $_POSTї'Looked_Like'];
$typeї'Misc'] = $_POSTї'Misc'];
$Table_names = array("Quality", "Ending", "So_Ugly", "So_Fat",
"So_Dumb", "Looked_Like", "Misc");Here's what I've got so far (which obviously isn't quite what I want). But it will be the array to end all arrays!
Code: Select all
* Table Name Column Name Relative Path to file Post variable ->Depriciated with $cat*/
$cat = array(
array("Quality" , "adjective" , "./files/quality.txt" , $_POSTї'Quality']),
array("Ending" , "end_phrase" , "./files/ending.txt" , $_POSTї'Ending']),
array("So_Ugly" , "phrase" , "./files/ugly.txt" , $_POSTї'So_Ugly']),
array("So_Fat" , "phrase" , "./files/fat.txt" , $_POSTї'So_Fat']),
array("So_Dumb" , "phrase" , "./files/dumb.txt" , $_POSTї'So_Dumb']),
array("Looked_like" , "phrase" , "./files/looked_like.txt" ,$_POSTї'Looked_Like']),
array("Misc" , "phrase" , "./files/misc.txt" , $_POSTї'Misc'])
);Code: Select all
$catї'Quality']ї'Column_name'] and get "adjective"Code: Select all
$catї'So_Fat']ї'Path'] and get "./files/fat.txt"Thanks,
Paul