finding similarities in array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

finding similarities in array

Post by shiznatix »

is there a way to use the awesome mysql LIKE function on arrays in php? i need to find elements of an array that are going to be simmilar to eachother
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

there isn't an efficient way.. but you can make your own in php fairly easily... hint: strtolower() :arrow: strstr()
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Take a look at chapter on array functions in php manual.

f.e. array_filter, usort, array_walk. Using these functions + some regexps you're certainly able to implement LIKE and alike in php :)
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

There's probably already functions out there for returning the % of similarity between 2 strings.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

yes, there are.. but they tend to.. shall we say, be expensive (in execution time)
Post Reply