poldixd / integer-hash
Generates a not unique integer hash from an integer. You can set a optional max size parameter.
0.1.1
2017-06-19 10:14 UTC
Requires
- php: >=5.6.4
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2024-10-28 14:36:11 UTC
README
Generates a not unique integer hash from an integer. You can set a optional max size parameter.
Usage
$int = 30211;
return integer_hash($int);
// returns 8
If you want a number that is lower than 5 use the second parameter.
$int = 30211;
return integer_hash($int, 5);
// returns 4
Example
I created this package for SEO purposes. I have an array with 5 SEO Meta Descriptions and my data in the database should choose a item from my SEO Meta Description Array by the database ID.
Known Issues
The generated Hash is different on each system! I get different results on my local computer and on the web server.
License
Integer Hash is licensed under the MIT License.
Copyright 2017 Nils Poltmann