Jump to content

Sort Array


ojsimon

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.