php - Regular expression to change user input -


I am searching on my database if the user enters the example "Foo bar" I want to display those lines I am both in "foo" and "bar"

My SQL syntax looks like this: SELECT * FROM t1 WHERE MATCH (t1.foo_desc, t2.bar_desc) ('+ Foo * + bar *')

I How can I change user input "foo bar" to "+ foo * + bar *" by using a regular expression? 'match =' text '> match =' + 'implode (' * + ', explosion (' ',

$ Input)). '*';

It assumes that the input is not empty string;

EDIT: As @BurT S, str_replace (or mb_str_replace if you are working with multibyte characters) will also be simpler ...

  $ match = '+' Str_replace ('', '* +', $ input). '*';  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -