Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    217
    Thanks
    1
    Thanked 0 Times in 0 Posts

    how to perform search in a .inc file ??

    Hello forums!!
    I have the following question
    1> i hava a file with .inc extension(here i had given filename.inc) and it contains the comma separated values as "EnglishWord"=>"DutchWord" , etc..
    I want to perform the search in this file in such a way that -
    if the user enters the word in a dutch then it should look in the file and give the corresponding english word
    For example
    if i entered the word 'Adres' and it should give the 'Address' as result

    filename.inc

    Code:
    "About"=>"Betreft",
    "Active Projects"=>"Actieve Projecten",
    "Add"=>"Toevoegen",
    "Address"=>"Adres",
    "Administration"=>"Administratie",
    "All"=>"Alle",
    How to perform such search in this file ?
    I would really appreciate any help from forums .
    Thanks in advance to all of you !!
    Last edited by PHPycho; 03-16-2007 at 12:50 PM.

  • #2
    New Coder
    Join Date
    Jul 2005
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well if you assign the content of file to string then convert it to an array it would be pretty easy for you to search in it. And the format of file will make such an operation possible.

    PHP Code:
    <?
    $str 
    file_get_contents("somefile.inc");
    //remove last comma in a string
    $str substr($str0, -1);

    //make an array
    $arr = array($str);

    //when you search a word just the following
    //assuming search term to $search

    if (isset($arr[$search])) return $arr[$search];

    $swap array_flip($arr);

    if (isset(
    $arr[$search])) return $arr[$search];

    else return 
    "No match";


    ?>
    If you can not find a decision, maybe you have to try to change a problem

    http://www.gunman.co.nr
    http://bglinux.org

  • #3
    Regular Coder
    Join Date
    Dec 2005
    Posts
    217
    Thanks
    1
    Thanked 0 Times in 0 Posts
    If i go for the database design what would be the table structure for translation?
    Here mine attempt is the following:
    ---------------
    | translation |
    ----------------
    |id
    |translation_english
    |tranlation_dutch
    |translation_spanish
    |translation_frenc
    |...etc

    I dont know whether that table is perfect for the translation or not.
    Any suggestion regarding the translation database are warmly welcome..
    Thanks in advance to all of you !!

  • #4
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Please don't use .inc as an extension for PHP files. It will only cause headaches. If it is a PHP file, name it something.php. Not .inc, or .phtml.

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Another reason for not naming them .inc is that most servers will serve them as plaintext, so people would be able to see your code, and possibly any sensitive information you have(such as usernames/passwords).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •