What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Searching for similar variable - php

Searching for similar variable - php
Author: Message:
stoshrocket
Senior Member
****

Avatar
formerly methos

Posts: 748
Reputation: 31
34 / Male / Flag
Joined: Aug 2005
O.P. Searching for similar variable - php
I've got a script that searches a simple text files line by line for a stated string, but I also wanted to search for "similar" strings. So, for example, if we had the following in list.txt
code:
frig
frag
brag
grand
train

and "frugle" was seached for, it would return, "did you mean: frig? frag?" or something similar.

any ideas how I'd go about it?
formerly methos
06-30-2009 08:15 PM
Profile PM Web Find Quote Report
prashker
Veteran Member
*****


Posts: 5109
Reputation: 104
– / Male / –
Joined: Mar 2005
Status: Away
RE: Searching for similar variable - php
Do something with similar_text()

php code:
<?php
$list = file('list.txt');
$string = "dog";

foreach $list as $tree {
     similar_text($string, $tree, $percent);
    if ($percent > 75) {
        echo 'Did you mean' . $tree . '?';
    }
}
?>

This post was edited on 06-30-2009 at 08:47 PM by prashker.
06-30-2009 08:41 PM
Profile PM Find Quote Report
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
32 / Male / Flag
Joined: Mar 2003
RE: Searching for similar variable - php
This may help a little (especially the first result): http://www.google.com/search?hl=el&client=firefox...%F4%E7%F3%E7&meta= :)
YouTube closed-captions ripper (also allows you to download videos!)
06-30-2009 08:42 PM
Profile E-Mail PM Web Find Quote Report
stoshrocket
Senior Member
****

Avatar
formerly methos

Posts: 748
Reputation: 31
34 / Male / Flag
Joined: Aug 2005
O.P. RE: Searching for similar variable - php
Both are perfect, thanks guys!
formerly methos
06-30-2009 09:23 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On