Posted 23 January 2013 - 01:22 PM
Posted 23 January 2013 - 02:57 PM
But yes, you can store data in a file. You can find many tutorials on file read/write if you google it.
How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq
Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!
Posted 23 January 2013 - 04:38 PM
Either way, here is a quick example of how you could use arrays in PHP for this. Surely there are better ways (especially if you use a database), but perhaps it is enough to get you started.
$words = array( 'beautiful' => array('handsome', 'pretty', 'lovely'), 'funny' => array('comical', 'amusing', 'humorous', 'laughable'), 'clever' => array('smart', 'intelligent', 'ingenious') );
To save it to a file, you can can serialize the array (Google should help you out here).
Each word has an array of synonyms. Imagine that for each of those words, you would have an array of all of the other synonyms. For instance, an entry for the word "smart" would have an array of "clever", "intelligent", "ingenious", and so on. You can use references, but I think you will end up overcomplicating things - and worse yet, you will probably not be able to leverage so much from the experience since it is probably far away from what you will face when doing "real" applications. So my advice is to keep it as close to how you would do it if you were paid to do it for someone.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users