0

Hi,

I have a list of several thousand words that I want to use to create a list of all possible combinations of those words (only two words in each combination though).

e.g.
word1
word2
word3
word4

to

word1word2
word1word3
word1word4 and so on.

I would usually do this in excel but it is proving too slow, so I plan to try in PHP.

I don't have much of an idea on how to approach this, does anyone have any suggestions.

Thanks in advance

3
Contributors
2
Replies
19
Views
2 Years
Discussion Span
Last Post by Excizted
0

It will be slow in any programing language.
You can try to put that words in memory but I don't know if you can do that. Maybe your file is too big for that.
Then combinate one word with others.
When you finish that you need to know do you need word1word2 and word2word1.
If you don't need second thing then after doing everything with word1 + wordN
you can delete word1 that will speed up a little. But as I said I think it will be slow in any programing language you do it...
And yes please define "SLOW".
Regards, Mike.

0

You should load in all the words in a PHP array.

As milil suggests, this will take up a lot of memory. Basically consider the size of your text file, and expect to need this much memory (RAM) on the machine that will run this script. In addition you will need to set the php directive for maximum allowed memory usage, do this with the function ini_set.

Set up a loop that will combine all your words, and then output that word to a text file or flush it to echo (display on screen). If you have enough memory and also need to post process the words, store them in memory, that's faster.

Edited by Excizted

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.