php代码使用星号搜索单词变体(*)[关闭]

I want to make search box with ability to search for word variations using the asterisk (*).

An asterisk (*) replaces one letter, can be used more than once in a word.

For example, searching on the term wom*n will locate records containing both woman and women and so on...

Any tips to achieve this in PHP ?

Assuming you wil do this with a database.

// The var we will use: $_POST['var']

$query = "SELECT  FROM yourTable WHERE name LIKE ".translateVar($_POST['var']);

function translateVar($n){
    return str_replace("*", "_", $n);
}