PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Basically I am a novice PHP user but I am trying to get into it. I have created a simple script which creates a list of words after running the entered word through a PHP class (the class generates words related to the word typed in). So here is what I have:
Now what I want to do is to add the list of words that the above script outputs into another variable ($list). How would I go about getting this done? I am thinking this would be something extremely simple but I just can't get it . Help would be much appreciated!
You already have the list of words in the '$related' array that you are iterating over to produce your html output. What exactly are you trying to do? Your question seems to suggest that you simply need to do this:
Thanks for the reply. Ok what I actually want to do is as follows. I don't want to output the list of words to html I want to use them within another script . This other script is using a variable which contains ($query= 'item') I want to replace the 'item' with the generated list that my script outputs, this list changes depending on the word input to my form. If that makes sense lol
MikeBlade wrote:Thanks for the reply. Ok what I actually want to do is as follows. I don't want to output the list of words to html I want to use them within another script . This other script is using a variable which contains ($query= 'item') I want to replace the 'item' with the generated list that my script outputs, this list changes depending on the word input to my form. If that makes sense lol
OK, so I am assuming you want perhaps a comma-separated string comprising the output of your class.
Will give you "word1, word2, word3". I would recommend, however, that if you're storing words that relate directly to another word that you use a properly relational approach and store each word in $related as a separate row in the database with an identifier, but that's up to you