PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 3rd, 1999, 12:02 PM
ascii
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Hi,

i'm having a go at coding a simple, quick-n-dirty searchengine, which involves the similar_text() function. However, I can't seem to get it to calculate the percent-wise similarity between two variables. The manual states that to the syntax:

int similar_text(string first, string second, double [percent]);

adding the third argument as a 'reference' (what's that?) will calculate the similarity in percent. How would I get that value?

Thanx in advance.

Thomas, Denmark

Reply With Quote
  #2  
Old August 5th, 1999, 06:31 PM
jpenix
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Untested, but I think this is how it'd work:

$a = similar_text("bear", "bean", $b);

After the function runs, $a would have the integer value '3' because there are 3 letters that are the same. $b would have the double-precision real number .75 (or maybe 75) because 3/4's of the letters match.

What you're seeing is a sneaky way of getting a function to return two variables.

Reply With Quote
  #3  
Old August 6th, 1999, 02:50 AM
ascii
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Yeah, that's exactly what I thought, however I never get a return value from $b - there's simply no output at all when i print the variable.

Any suggestions?

Regards - Thomas

Reply With Quote
  #4  
Old August 6th, 1999, 07:05 PM
scollo
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Do you mean, "pass by reference"?

To do so, place a & before the variable name.

a_function (&$x) {

}

$y = a_function (&$z);

--Chris

Reply With Quote
  #5  
Old August 7th, 1999, 04:44 AM
ascii
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Thanx a bunch - that did the trick! And I even found it now in the manual. Kinda embarrasing now that you've provided the solution, but I was a bit confused about the reference-part that was a bit blurry methinks.

Anyway, thanks again and cheers.

- Thomas

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Similar_text() syntax problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway