portia Posted August 29, 2011 Share Posted August 29, 2011 Hi there, I'm learning PHP and decided that I'll try to create a word search generator for my own use. I know there are hundreds of them out there but it's just for learning purposes. I'd like to enter a number of words and then the script should generate a pdf containing a box filled with random letters (among which there will be my words). My question is what keywords/functions should I look at to get started? I'm a php beginner but would like to make my learning more interesting by doing this project. The form with words should be easy, it's the next bit where it's supposed to generate a pdf containing words that I have no idea about. thank you Quote Link to comment https://forums.phpfreaks.com/topic/245962-php-word-search-generator/ Share on other sites More sharing options...
MarPlo Posted August 29, 2011 Share Posted August 29, 2011 Hy, You can generate a HTML code, then use the dompdf class, which is a free HTML to PDF converter, you can find it on the net. Quote Link to comment https://forums.phpfreaks.com/topic/245962-php-word-search-generator/#findComment-1263223 Share on other sites More sharing options...
QuickOldCar Posted August 29, 2011 Share Posted August 29, 2011 http://php.net/manual/en/function.pdf-new.php And the rest of the PDF functions are to the left. Here's an example way to do it in php. http://astahost.com/info.php/Create-Pdf-Php_t4972.html Quote Link to comment https://forums.phpfreaks.com/topic/245962-php-word-search-generator/#findComment-1263226 Share on other sites More sharing options...
Psycho Posted August 29, 2011 Share Posted August 29, 2011 I would forgo the PDF portion at this point and just make an HTML table with the letters. If you are learning, there is no need to over-complicate this. Once you can do that - then you can learn the process of making PDFs. As for making the word search, that is an interesting problem. Trying to program the logic to dynamically determine the positions of the words will take some effort. You have to be able to get words to cross-over each other and share some letters. To do that would take some analysis of the words before you start, otherwise you may only get a handful of words in the grid and none of the remaining words would fit. The only suggestion I can think of would be to start with the longest words and work backwards. I'm sure this is possible, but it is not a trivial task by any means. I would highly suggest that before you even start coding that you get out a piece of paper and write out the logic you want to use to determine placement of the words. If you can't come up with the logic, no amount of functions are going to help. If I were doing this I would probably use a multidimensional array to store the letters. Quote Link to comment https://forums.phpfreaks.com/topic/245962-php-word-search-generator/#findComment-1263239 Share on other sites More sharing options...
portia Posted August 29, 2011 Author Share Posted August 29, 2011 Thanks a lot for your replies. I'll look at the links. On a separate note, I think you're right about thinking it over first before coding anything. The more I analyse it (with my limited knowledge of PHP and programming in general), the more I realise that I actually have no idea how to place those words on a grid among random letters. Quote Link to comment https://forums.phpfreaks.com/topic/245962-php-word-search-generator/#findComment-1263247 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.