Trying to create a search for users where I have an array like this:
Original Array:
array(2) {
[1]=>
array(1) {
["string"]=>"One two three, Blue, Green, Yellow"
}
[2]=>
array(1) {
["string"]=>"One two four, Blue, Green, Yellow"
}
}
Now how can I do a regex with the words from input field which could be "one two blue four" and then change the given array order (in this case to):
array(2) {
[1]=>
array(1) {
["string"]=>"One two four, Blue, Green, Yellow"
}
[2]=>
array(1) {
["string"]=>"One two three, Blue, Green, Yellow"
}
}
Cause Original Array [2] has got more matches. Also I would like the order to change already if a user writes "one two blue f"
I've tried with array_diff but I need some opposite array_diff function (showing all the matches) and probably a regex to make it work with single letters.
Any advices would be much appreciated!