How to display words from a txt in PHP regarding a defined variable?

  • Thread starter Thread starter JR Polidario
  • Start date Start date
J

JR Polidario

Guest
I have .php webpage similar to this:
http://www. mywebsite. com/page.php?imageid=xxxx
where xxxx is an image.

For a particular xxxx, example would be "flower", i wanted to display group of words from an external txt file.

Something like this:
ex. if i type http://www. mywebsite. com/page.php?imageid=flower ,
the page will show:
red, fragrant, small

The "red, fragrant, small" came from a .txt from the same directory. And, then, if "flower" is change into "food", a different result should show in the page.

Please help me here. I'm just a beginner in php scripting, and I can only understand very basic php language.
 
This is possible however not really with basic PHP. I would recommend you learn to use a database, like MySQL, it is much easier and much more efficient. To do it with the txt file you would need to use the fpopen() function and then you would need to use explode() or preg_grep() or substr() or some other function to somehow seperate the variables and the words associated with them, store them in arrays then search through the arrays for the words.
 
Back
Top