Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

untymage's avatar

Find the records that contain this words in any order

Let say i have this title on my threads table:

Laravel Airlock

How can i find this record when a user doesnt use a space ? for example laravelairlock or airlocklaravel

I tried LIKE operator:


$input = 'laravelairlock';

$results = Thread::query()->where('title', 'LIKE', "%$input%")->get();

But it not working How can i act like google ? : )

0 likes
4 replies
untymage's avatar

So we cannot gain this and have to pay to a external services?

artcore's avatar

As alternatives, perhaps use regex on mysql or use something like levenshtein as function on your db

where `column` REGEXP 'laravel|airlock*';

google "create function mysql levenshtein"

eventually do:

SELECT levenshtein('laravel', 'airlock')

// returns the distance, lower is better
// also matches typos like laraeel and airlick ;)

Please or to participate in this conversation.