Page 1 of 1

how to perform search in a .inc file ??

Posted: Fri Mar 16, 2007 1:43 am
by PHPycho
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: Select all

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

Posted: Fri Mar 16, 2007 2:45 am
by mikeq
In terms of searching would it not be quicker/easier to load the values into a database table and search that rather than searching a text file?

Posted: Fri Mar 16, 2007 4:05 am
by PHPycho
Thanks for the reply..
I know that idea but this is the requirement of the client..
Any suggestion would really matter..
Thanks in advance

Posted: Fri Mar 16, 2007 5:59 am
by Skittlewidth
Given the format of the text file, I wonder if it would be possible to have PHP load that into an array, and then depending on the mode you are in, find the associated key for the value, or value for the key? Just an idea

Posted: Fri Mar 16, 2007 6:18 am
by Mordred
If this is 100% trusted data (i.e. only site admin can change it), you may indeed try Skittlewidth's idea:

Code: Select all

eval('$aTranslation = Array(' . file_get_contents('filename.inc') . ');');

Posted: Sun Mar 18, 2007 11:26 pm
by PHPycho
n terms of searching would it not be quicker/easier to load the values into a database table and search that rather than searching a text file?
Ya i realized so..
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 !!