Hi All,
I'm doing a site with multiple languages. I've got a Language Object that will store phrases pulled from a MySQL database depending on the language_id passed to it in its constructor. For example:
$Eng = new Language('en');
When instantiated, the attributes in the Language object $Eng will be assigned values from the database, in this case where the row id is equal to 'en'.
1) My problem is, I have over 25 short phrases for each language. Obviously it's not a good idea to have over 25 lines of code used to assign values to each of the attributes in the Language object ie: $phrase1 = $rw['phrase1'];. Is there any way to code this, "value assignment" more efficiently?? The variable names in the Language object are the same as the column names in the database table that stores the phrases in the different languages. However the naming isn't consistent. For example the attribute name that stores the language specific equivalent for "truck" is called $truck (not $phrase1, $phrase2) etc etc..
2) Obviously I don't want to be creating this object every time a page is loaded. Therefore am I able to store this object as part of a session?
Any help very much appreciated!!
Thanks in advance,
Richard.