Jump to content

denniso

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by denniso

  1. Hi all! First I'd like to say that this is the greatest of communities and you guys helping others are worth all respect! OK, here is my question. I've made an Online Thai to English dictionary. When someone search for a word I look up the searchword in the database sorrounded by "%". I search in 2 fields, the "search word" field and in the "related words" field. The problem is that sometimes the query can return a lot of matches from the database. For example is someone likes to look up the word "cat" i get 23 pages with 50 results each. See for your self: http://english-thai-dictionary.com/index.php?action=dictionary;sa=search;fields=related;search=cat Now. I would like to put the exakt matches first in my result (if there are any exact matches ...) This record for example .... http://english-thai-dictionary.com/index.php?action=dictionary;sa=details;id=9397 is an exact match of the given search string. The search result is stored in an array like this: $dictionaryContext[$item] = array( 'ID' => &$the_data['ID'], 'S' => &$the_data['S'], 'FL' => &$the_data['FL'], 'TL' => &$the_data['TL'], 'FLWC' => &$the_data['FLWC'], 'flwctext' => $flwctext, 'FLSamp' => &$the_data['FLSamp'], 'FLOpp' => &$the_data['FLOpp'], 'FLSyn' => &$the_data['FLSyn'], 'Cls' => &$the_data['Cls'], 'FLDef' => &$the_data['FLDef'], 'TLSyn' => &$the_data['TLSyn'], 'FLNotes' => &$the_data['FLNotes'], 'TLNotes' => &$the_data['TLNotes'], 'StyleLevel' => &$the_data['StyleLevel'], 'styleleveltext' => $styleleveltext, 'StyleAge' => &$the_data['StyleAge'], 'styleagetext' => $styleagetext, 'StyleGroup' => &$the_data['StyleGroup'], 'stylegrouptext' => $stylegrouptext, 'StylePower' => &$the_data['StylePower'], 'stylepowertext' => $stylepowertext, 'StyleGeneral' => &$the_data['StyleGeneral'], 'stylegeneraltext' => $stylegeneraltext, 'Transliteration' => &$the_data['Transliteration'], 'Pending' => &$the_data['Pending'], 'EstablishedBy' => &$the_data['EstablishedBy'], 'LastUpdatedBy' => &$the_data['LastUpdatedBy'], 'TimeCreated' => &$the_data['TimeCreated'], 'TimeUpdated' => &$the_data['TimeUpdated'], 'EstablishedByUsername' => &$the_data['EstablishedByUsername'], 'EstablishedByUserID' => &$the_data['EstablishedByUserID'], 'LastUpdatedByUsername' => &$the_data['LastUpdatedByUsername'], 'LastUpdatedByUserID' => &$the_data['LastUpdatedByUserID'] ); I would like to sort the array in relevance order. That is, first I would like to put exakt matches, secondly comes matches where the search string is part of a string but sorrounded with spaces (or is at the start or at the end of the string)... like ' a <b>cat</b> ate my dog' or '<b>cat</b> people'. After that I would like to put any matches that has the searchword as a start or an ending, like '<B>cat</B>alogue'. Then the rest follows in alfabetical order .... I have no clue in how to reorder my array and howto sort it ... can you help me a little bit in the right direction? Thanks a lot in advance! Dennis
  2. Thank You @effigy !!! It looks like a nice solution. I will use it !!! I think it was very kind of you to help me and share your experience! Thanks! Dennis
  3. Hi! I'm trying to modify an URL string with preg_replace in my SMF board ($buffer contains all the HTML code for the web page) There is some code for similar purposes already: $buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?"/e', "'\"' . \$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2\"'", $buffer); It will replace all occurences of the URL http://chaimai.com/index.php?board=2.0 with http://chaimai.com/index.php/board,2.0.html and http://chaimai.com/index.php?topic=1666.0 with http://chaimai.com/index.php/topic,1666.0.html and http://chaimai.com/index.php?topic=1281.msg5110#msg5110 with http://chaimai.com/index.php/topic,1281.msg5110.html#msg In the example above $scripturl is set to "http://chaimai.com/index.php" I need to modify it (or make several calls to preg_replace) so it will Replace http://chaimai.com/index.php?board=2.0 with http://chaimai.com/thailand/forum/2/0.html and http://chaimai.com/index.php?topic=1654.0#new with http://chaimai.com/thailand/topic/1654/0.html#new and http://chaimai.com/index.php?action=dictionary;sa=details;id=83239 with http://chaimai.com/thai/lexikon/83239.html I know it's a lot to ask but I will really be greatful to any help in the right direction ... Thank You! Regards Dennis
×
×
  • 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.