View Full Version : how to perform search in a .inc file ??

03-16-2007, 08:47 AM
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


"Active Projects"=>"Actieve Projecten",

How to perform such search in this file ?
I would really appreciate any help from forums .
Thanks in advance to all of you !!

03-16-2007, 02:47 PM
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.

$str = file_get_contents("somefile.inc");
//remove last comma in a string
$str = substr($str, 0, -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";


03-19-2007, 06:28 AM
If i go for the database design what would be the table structure for translation?
Here mine attempt is the following:
| translation |

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 !!

03-19-2007, 04:18 PM
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.

03-19-2007, 11:27 PM
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).