alanstone Posted December 10, 2007 Share Posted December 10, 2007 Hi, I hope I'm in the right forum, otherwise please don't shoot the pianist. ) ( 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 Quote Link to comment Share on other sites More sharing options...
dsaba Posted December 13, 2007 Share Posted December 13, 2007 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.