how to perform search in a .inc file ??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

how to perform search in a .inc file ??

Post 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 !!
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post 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?
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

Post 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
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post 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
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post 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') . ');');
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

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