Skip to main content
Inspiring
Aug 10, 2011 8:10 AM UTC
Question

Split text in field into two boxes

Hiya

I am setting up a bi-lingual website where the left hand column is in English and the matching right hand column is in French.

Is there a way to use ONE field from the database and split the information like this:

<special tag here around English>

English Text

English Text

English Text

</special tag here around English>

<special tag here around French>

French Text

French Text

French Text

</special tag here around French>

Any ideas?

This topic is closed to new replies. Start a new post to keep the conversation going.

7 replies

Inspiring
Aug 10, 2011 5:41 PM UTC

You could, but it's asking for trouble.

If you will forever be only bilingual (and not multilingual) you could add a field (column) and have English in one, French in the other. If you will ever be going multilingual then add a field to identify the language (language_id or whatever) and a new record (row) for each entry. In either case you will need to deal with blank/missing entries.

Ed

Translate
Lon_Winters
Inspiring
Aug 10, 2011 5:17 PM UTC

What exactly is contained in the one database field?

Translate
Inspiring
Aug 10, 2011 7:24 PM UTC

The text for the web page. So details about the school (in French first). Then the same text translated into English.

I know adding another column to the DB would be easier on the page, but as I am making the changes to a Wordpress blog it would be a nightmare to coordinate the different versions of the page in both French and English.

All I really need is to make this schematic work:

if ( $frenchTag . $the_Text_in_French . $endFrenchTag ) { echo $the_Text_in_French }    // this goes in the french text box

if ( $englishTag . $the_Text_in_English . $endEnglishTag ) { echo $the_Text_in_English }    // this goes in the english text box

I know the sytax is all over the place, but that is what I need help with please!

Translate
Inspiring
Aug 11, 2011 7:56 AM UTC

Cludgy way:

Fill your field as follows [En francais#&&#In English] - i.e. #&&# is unlikely to be input elsewhere as normal text, then use

explode:

$fieldtext = explode('#&&#', yourfield);

In the French box: echo $fieldtext(0);

In the English box: echo $fieldtext(1);

Better way:

Use preg_replace or preg_split (but you will have to ask someone more experienced than me to help you with the regular expression!)

Translate