Page 1 of 1

preg_replace - but where and how?

Posted: Thu Feb 12, 2009 5:18 pm
by Greg_BigPhpAmator
I have this code.

Code: Select all

 
<html>
<head>
</head>
<body>
<?
include("class.xml.parser.php");
include("class.weather.php");
$timeout=3*60*60;  // 3 hours
$tc=100;
 
if (isset($_ENV["TEMP"]))
  $cachedir=$_ENV["TEMP"];
else if (isset($_ENV["TMP"]))
  $cachedir=$_ENV["TMP"];
else if (isset($_ENV["TMPDIR"]))
  $cachedir=$_ENV["TMPDIR"];
else
  $cachedir="/tmp";
 $cachedir=str_replace('\\\\','/',$cachedir);
if (substr($cachedir,-1)!='/') $cachedir.='/';
$weather_chile = new weather("CAXX0518", 3600, "C", $cachedir);
$weather_chile->parsecached(); 
 
print "<img src=http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_chile->forecast['CURRENT']['CODE'].".gif>";
print "<h1>Actual Situation</h1>";
print "acttext: ".$weather_chile->forecast['CURRENT']['TEXT']."<br>";
print  round(($weather_chile->forecast['CURRENT']['TEMP'] - 32)*(5/9));
print "<br>";
print "acttime: ".$weather_chile->forecast['CURRENT']['DATE']."<br>";
print "actcode: ".$weather_chile->forecast['CURRENT']['CODE']."<br>";
 
?>
</body>
</html>
 
Line:
print "acttext: ".$weather_chile->forecast['CURRENT']['TEXT']."<br>"
display weather conditions. How to replace this condition with other word. I would like to translate all possible words to other language.
I know I can use preg_replace function. But how it fit in this code? Please help.

Re: preg_replace - but where and how?

Posted: Tue Feb 17, 2009 6:57 pm
by LanceEh
Greg, if you are getting this from an XML file, then it will display the language it's written in. I don't know how you would change this except to find a feed in another language.

Lance