1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Rep Power

    Compare multidimensional array elements

    Ok this is going to take some careful explaining. Here is my code.

    PHP Code:

    if(isset($_POST['input']) && $_POST['input'] != "")


    "<br />Your Search Result Array Blekko:<br /><br />";
    $u_r_l =  cantsay
    ($u_r_l );

    $body file_get_contents($u_r_l);

    //echo $js;
    foreach ($js['RESULT'] as $data) {
        echo '
                ', $data ['url_title']," ---> <u>Blekko SE </u>" ,'<br />
                ', '<a href ='.$data['url'].'>'.$data['url']."</a>" , '<br />';
                if (empty ($data['snippet']) != true)
                echo $data['snippet'];  
    else echo"<p>";


    $blekko_score 0;
    $js['RESULT'] as $data)

    $blekko_array[] = array (

    $blekko_score is the score I want to assign for the url, and $blekko_score is the element at $blekko_array[0-99][1][1]). I have two other engines and i need to merge the url scores of the 3 engines into one large array. I then need to add the scores of duplicate urls together and display the 100 top results, along with the title. I have 2 days to do this and don't think I have a snowballs chance in hell of getting this done, thought that adding an incrementing score to a url and comparing the results wouldn't be that difficult, but has so far had loads of complications - incrementing counters don't work within foreach loop, simply giving a score to the element in the array, comparing elements of different arrays etc. The code for the other Search-engines is on the same page and is similar so if i can get the structure of this I'm confident I can twist it to suit the others.

    If anyone has any pseudo code, general advice, alternative solutions etc I'd really appreciated it, this has set me back for two days already.
  2. #2
  3. Impoverished Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Washington, USA
    Rep Power
    Put the URLs and scores into an array like
    PHP Code:
    $blekko_array[$url] = $score
    a) If the URL already exists in the array (check with isset()) then add to the score
    b) Otherwise add it as a new item

    Then arsort.

IMN logo majestic logo threadwatch logo seochat tools logo