1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Sort Array

Discussion in 'PHP' started by ojsimon, Jan 24, 2008.

  1. #1
    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
     
    ojsimon, Jan 24, 2008 IP
  2. tarponkeith

    tarponkeith Well-Known Member

    Messages:
    4,758
    Likes Received:
    279
    Best Answers:
    0
    Trophy Points:
    180
    #2
    Easy, start by posting this in the buy/sell/trade->programming section, and offer a small paypal reward for the person that helps you out :)

    Sorry, but that seems like a lot to ask for free
     
    tarponkeith, Jan 24, 2008 IP
  3. ojsimon

    ojsimon Active Member

    Messages:
    459
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    hi
    i found an algorithm http://www.webmastersherpa.com/content/useful-code/32/ but i tried just replacing the sort and it didnt work how can i make this work, my script uses 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
     
    ojsimon, Jan 26, 2008 IP