convert (nearly) any value into an id-string


/ Published in: PHP
Save to your folder(s)

convert any value into an id-string


Copy this code and paste it in your HTML
  1. function hash($input)
  2. {
  3. //Create unsigned crc
  4. $input=abs(crc32(serialize($input)));
  5.  
  6. //Build a string representing the crc32
  7. $result="";
  8. while ($input > 0)
  9. {
  10. //Use only a-z
  11. $result.=chr( ($input % 26) + 97);
  12.  
  13. //Decrease value
  14. $input=$input >> 2;
  15. }
  16. //Done
  17. return($result);
  18. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.