Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8200575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:29:47+00:00 2026-06-07T06:29:47+00:00

I am making a simple php file for matching the string entered by the

  • 0

I am making a simple php file for matching the string entered by the user which searching for a group which suits him.
I need to display 5 records from the database which match the string to the maximum extent.
I also tried soundex() function in php and mysql.
I am now trying to design a regex pattern matcher for this purpose.
Can anyone suggest me a sample regex pattern for this purpose?
Is there any other way which can be implemented easily and is not too complex/time consuming.
I tried doing this with code using a distance algorithm
Want I is basically
Eg user types in “dps”

The php should retrieve thos

<?php
function minimum($a,$b,$c)
{
    if($a>$b)
    {
        if($a>$c)
        {
            return $a;
        }
        else
        {
            return $c;
        }
    }
    else
    {
        if($b>$c)
        return $b;
        else
        return $c;
    }
}
function Distance($s ,   $t)
{

  $m=strlen($s);
  $n=strlen($t);
  $d[]=array();
for( $i=0;$i<$m;$i++)
{

    for($j=0;$j<$n;$j++)
    {

        $d[$i][$j]=0;

    }

}

for ( $i=0; $i<$m;$i++)
  {
    $d[$i][0] = $i;
  }
for( $j=0;$j<$n;$j++)
  {
    $d[0][$j] = $j;
  }

  for ($j=1;$j<$n;$j++)
  {
    for ($i=1;$i<$m;$i++)
    {
      if ($s[$i] ==$t[$j])
        $d[$i][$j] =$d[$i][$j];       // no operation required
      else
        $d[$i][ $j] = minimum
                   (
                     $d[$i-1][ $j] + 1,
                     $d[$i] [$j-1] + 1,
                     $d[$i-1][ $j-1] + 1
                   );
    }
  }

  return $d[$m-1][$n-1];

}

?>`
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:29:49+00:00Added an answer on June 7, 2026 at 6:29 am

    Well there are many methods to achieve that :

    • You could try Levenshtein : http://php.net/manual/en/function.levenshtein.php which is used to calculate the distance between two strings
    • Considering regexp, you will encounter troubles if you can have different string lengths…
    • Another option would be to consider ElasticSearch (http://www.elasticsearch.org/) or Solr(http://lucene.apache.org/solr/) if you have a lot of text data, this might turn out to be the best option
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple PHP script which lets the user upload an image. These
I'm making simple http post request using libcurl to index.php file on my web
Making a simple application, so when the user logs out of Windows, it of
I am making a simple development tool for myself using PHP on my local
I am making a PHP utility that imports and analyzes a CSV file into
I am making a simple PHP and JavaScript multiplayer game. Here is a quick
I have a php file which pulls some data from external API's, and I
I'm making a simple call from a file that's included in various pages. $.post(
I am making consecutive http get request to a PHP file on my server.
I cannot do a simple commit (svn commit file.php) from within the working directory.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.