#1
  1. No Profile Picture
    ascii
    Guest
    Devshed Newbie (0 - 499 posts)
    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
  2. #2
  3. No Profile Picture
    jpenix
    Guest
    Devshed Newbie (0 - 499 posts)
    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.
  4. #3
  5. No Profile Picture
    ascii
    Guest
    Devshed Newbie (0 - 499 posts)
    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
  6. #4
  7. No Profile Picture
    scollo
    Guest
    Devshed Newbie (0 - 499 posts)
    Do you mean, "pass by reference"?

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

    a_function (&$x) {

    }

    $y = a_function (&$z);

    --Chris
  8. #5
  9. No Profile Picture
    ascii
    Guest
    Devshed Newbie (0 - 499 posts)
    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

Similar Threads

  1. help needed with syntax problem
    By flaminstar in forum MS SQL Development
    Replies: 1
    Last Post: February 12th, 2004, 10:37 AM
  2. UTF-8 problem in 4.1.1a
    By mehran20 in forum MySQL Help
    Replies: 1
    Last Post: February 8th, 2004, 03:21 PM
  3. asp sql syntax problem
    By raw-edge in forum ASP Programming
    Replies: 1
    Last Post: February 3rd, 2004, 05:45 PM
  4. Wierd problem inserting data with VB6
    By gregquinn in forum MySQL Help
    Replies: 5
    Last Post: February 2nd, 2004, 08:37 AM
  5. Problem with Nested query syntax
    By skarulisap in forum MySQL Help
    Replies: 4
    Last Post: January 19th, 2004, 04:47 PM

IMN logo majestic logo threadwatch logo seochat tools logo