Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP Help - Parsing keywords?

Options
  • 28-09-2008 10:51pm
    #1
    Closed Accounts Posts: 94 ✭✭


    Hey,

    Thanks to everybody whos helped me with my projects on boards.ie, But I have another problem...

    I have 2 lists of keywords, seperated by ,

    Eg.
    list 1 = technology,linux,cool,gadget
    list 2 = technology,linux,computers

    these lists are strings

    I want it to find what keywords list 2 have in common with list 1.

    so in other words, it would return technology,linux.

    I only want it to take a maximum of 15 keywords, if there are less than 15 keywords in common, then it'll just populate it with keywords from list 1 and list 2 until it reaches 15 keywords.

    Anyone help me on getting started even? :)

    thanks!


Comments

  • Registered Users Posts: 3,594 ✭✭✭forbairt


    This should sort you out for comparing the two arrays
    http://ie2.php.net/manual/en/function.array-intersect.php


  • Closed Accounts Posts: 94 ✭✭gnomer


    forbairt wrote: »
    This should sort you out for comparing the two arrays
    http://ie2.php.net/manual/en/function.array-intersect.php

    thats the thing,they are strings, not arrays.


  • Registered Users Posts: 3,594 ✭✭✭forbairt




  • Registered Users Posts: 7,498 ✭✭✭corkie


    Try putting the keywords into a google search?

    64014.jpg

    Just wondering did you drop the music idea, you where previously working on?:rolleyes:


  • Closed Accounts Posts: 94 ✭✭gnomer


    corkie wrote: »
    Try putting the keywords into a google search?

    64014.jpg

    Just wondering did you drop the music idea, you where previously working on?:rolleyes:

    Long story, but I can't use Google to do it, this bit of code is part of a massive project which i will reveal probably next year.

    Yes I dropped that music idea, advertisers didn't like the sound of it so funding was impossible...


  • Advertisement
  • Closed Accounts Posts: 1,200 ✭✭✭louie


    [php]
    $common_list = "";
    $list1 = "keyword1,keyword2";
    $list2 = "keyword2,keyword3";

    $x_list = explode(",",$list1);
    $y_list = explode(","$list2);
    foreach($y_list as $x){
    if(in_array($x,$x_list){
    $common_list .= $x.",";
    }
    }
    echo $common_list != "" ? $common_list : "no common words";
    [/php]

    just a quick example. might get you started.


Advertisement