random - In php how would I generate a fixed number from a string within a certain value range -


Suppose I have a database of 100,000 or less random string and I want to generate a number from 1 and 1 in each string. 500

My method should always generate the same number (given to the same string) and it should also be a distribution of numbers from 1 to 500.

Any thoughts?

It seems that you need a hashing function, you can use and:

  echo (crc32 ("hello world"))% 500 + 1;    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -