Jump to content

replacing text in a php generated html page


alanstone

Recommended Posts

Hi,

 

I hope I'm in the right forum, otherwise please don't shoot the pianist.  :o)

( I'm not a programmer and don't know anything about php )

 

I have a (protected) php script generating html pages and want to translate a number of english words, if they appear in the generated html page, into another language.

 

Is the following possible ?

 

Use an intermediate php script

http://www.mywebsite.com/intermediate_script.php

which

 

(1) initiates the (protected) php script and generates the html page (with english text)

 

(2) searches and replaces what has to be replaced (into another language) - max. 10 words

 

(3) shows the translated page

 

If so, how do you do that ?

 

Thank a lot on beforehand for your kind help.

 

Best,

Alan

 

PS using php 4.4.4

 

 

 

Link to comment
Share on other sites

I'm not a programmer and don't know anything about php

Well, unless you want to pay a freelancer to do it for you, you're going to have to teach yourself some things about php, to get this done.

see these functions for getting done what you want:

http://us.php.net/str_replace (non regex solution)

http://us.php.net/manual/en/function.preg-replace.php (regex solution)

 

here's a simple example using parallel arrays and str_replace, it all depends on what and how you want to do what you're doing... if you have problems coming up with algorithim, post some sample input data and output data of how you want it, this is the best explanation you can give

 

<?php
$words_en = array('hello', 'see you later', 'welcome');
$words_es = array('hola', 'hasta luego', 'bienvenidos');
$str = 'hello welcome to my house, see you later!';
echo $str;
foreach ($words_en as $k => $enWord) {
$esWord = $words_es[$k];
$str = str_replace($enWord, $esWord, $str);
}
echo $str;
?>

 

good luck

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.