note 29221 modified in function.similar-text by danbrown

From: Date: Mon, 01 Mar 2010 15:55:28 +0000
Subject: note 29221 modified in function.similar-text by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-166477@lists.php.net to get a copy of this message
If you have reserved names in a database that you don't want others to use, i find this to work pretty good. I added strtoupper to the variables to validate typing only. Taking case into consideration will decrease similarity. <?php $query = mysql_query("select * from $table") or die("Query failed"); while ($row = mysql_fetch_array($query)) { similar_text(strtoupper($_POST['name']), strtoupper($row['reserved']), $similarity_pst); if (number_format($similarity_pst, 0) > 90){ $too_similar = $row['reserved']; print "The name you entered is too similar the reserved name &quot;".$row['reserved']."&quot;"; break; } } ?> --was-- If you have reserved names in a database that you don't want others to use, i find this to work pretty good. I added strtoupper to the variables to validate typing only. Taking case into consideration will decrease similarity. $query = mysql_query("select * from $table") or die("Query failed"); while ($row = mysql_fetch_array($query)) { similar_text(strtoupper($_POST['name']), strtoupper($row['reserved']), $similarity_pst); if (number_format($similarity_pst, 0) > 90){ $too_similar = $row['reserved']; print "The name you entered is too similar the reserved name &quot;".$row['reserved']."&quot;"; break; } } http://php.net/manual/en/function.similar-text.php

« previous php.notes (#166477) next »