ojsimon Posted January 24, 2008 Share Posted January 24, 2008 Hi At the moment i am merging several feeds together and they are currently displayed randomly the script uses a shuffle($all); what i would like to to is i will have another string which the user specifies, instead of shuffling i would like it to sort by relevance. After research i have found out that the only way to do this is have a script which rates the relevance on a scale, and then orders them ascending or descending depending on the scale. Am i right in thinking this? If not how can i do this? if it is the only way to do this, how can i make some code that will give them 4 points for having the exact phrase in the title, 3 points for having both word but not together in the title, 2 points for having any of the words entered, 1 point for everything else. how can i do this? Thanks Link to comment https://forums.phpfreaks.com/topic/87583-sort-array/ Share on other sites More sharing options...
ojsimon Posted January 26, 2008 Author Share Posted January 26, 2008 ok, so i just found this algorithm http://www.webmastersherpa.com/content/useful-code/32/ how do i use this instead of the sort Thanks Link to comment https://forums.phpfreaks.com/topic/87583-sort-array/#findComment-449901 Share on other sites More sharing options...
ojsimon Posted January 27, 2008 Author Share Posted January 27, 2008 please help me Link to comment https://forums.phpfreaks.com/topic/87583-sort-array/#findComment-450345 Share on other sites More sharing options...
ojsimon Posted January 27, 2008 Author Share Posted January 27, 2008 hi i found an algorithm http://www.webmastersherpa.com/content/useful-code/32/ Which i want to use on my rss feed merger instead of the shuffle which is in the code extract bellow, how do i do this? shuffle($all); foreach($all as $j=>$k) { if(!trim($k['title'])||!trim($k['link'])) unset($all[$j]); } return $all; } how can i make this work with the algorithm? Thanks Link to comment https://forums.phpfreaks.com/topic/87583-sort-array/#findComment-450356 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.