note 69978 added to function.ord

From: Date: Thu, 28 Sep 2006 19:47:09 +0000
Subject: note 69978 added to function.ord
Groups: php.notes 
Request: Send a blank email to php-notes+get-117790@lists.php.net to get a copy of this message
Well, i was thinking about a method to hash a string with md5 in a loose way, so md5("HELLO") isn't the same like md5("Hello"), even, i my case, it is about cd-titles i got submitted by users. So i made some function transforming my string to right what i want Thisone is the "call" function returning the "loose hash". It will get only the chars of a string, make them to uppercase and then hash with md5. function loosehash($string){ return md5(strtoupper(onlyChars($string))); } Thisone is moving through a string like a chararray and check for the asciivalues, you can edit the values and condition to fit your needs function onlyChars($string){ $strlength = strlen($string); $retString = ""; for($i = 0; $i < $strlength; $i++){ if((ord($string[$i]) >= 48 && ord($string[$i]) <= 57) || (ord($string[$i]) >= 65 && ord($string[$i]) <= 90) || (ord($string[$i]) >= 97 && ord($string[$i]) <= 122)){ $retString .= $string[$i]; } } echo $retString; } ---- Server IP: 212.124.37.9 Probable Submitter: 85.212.40.148 ---- Manual Page -- http://www.php.net/manual/en/function.ord.php Edit -- https://master.php.net/note/edit/69978 Del: integrated -- https://master.php.net/note/delete/69978/integrated Del: useless -- https://master.php.net/note/delete/69978/useless Del: bad code -- https://master.php.net/note/delete/69978/bad+code Del: spam -- https://master.php.net/note/delete/69978/spam Del: non-english -- https://master.php.net/note/delete/69978/non-english Del: in docs -- https://master.php.net/note/delete/69978/in+docs Del: other reasons-- https://master.php.net/note/delete/69978 Reject -- https://master.php.net/note/reject/69978 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117790) next »