I have a html file (get from another website) with time number inside it, then i print it to my website, like this:
<?php
$html = file_get_contents('//google.com/ls.html');
echo $html;
?>
Content of ls.html is here : http://pastebin.com/xF6zyRiS
But problem is time in ls.html is UTC+1, so i need to convert them to another timezone, UTC+7.
I just tried with str_replace, like this:
<?php
// I need ':' because in ls.html have another number i do not want to change, like minute of the match or match result number
$time = array("00:","01:","02:","03:","04:","05:","06:","07:","08:","09:","10:","11:","12:","13:","14:","15:","16:","17:","18:","19:","20:","21:","22:","23:");
$d_time = array();
foreach($time as $t){
$hour = $t."00"; // 00 appending 0 minites
$hours_plus = 6; // adding 6 hours
$d_time[] = date('H:', strtotime($hour)+($hours_plus*60*60));
}
$html = file_get_contents('//google.com/ls.html');
$result = str_replace(
array($time[0], $time[1], $time[2], $time[3], $time[4], $time[5], $time[6], $time[7], $time[8], $time[9], $time[10], $time[11], $time[12], $time[13], $time[14], $time[15], $time[16], $time[17], $time[18], $time[19], $time[20], $time[21], $time[22], $time[23]),
array($d_time[0], $d_time[1], $d_time[2], $d_time[3], $d_time[4], $d_time[5], $d_time[6], $d_time[7], $d_time[8], $d_time[9], $d_time[10], $d_time[11], $d_time[12], $d_time[13], $d_time[14], $d_time[15], $d_time[16], $d_time[17], $d_time[18], $d_time[19], $d_time[20], $d_time[21], $d_time[22], $d_time[23]),
$html
);
echo $result;
?>
I expected this number will +6, like: 17: => 23:
But 17: will become 05:, because 17 replace to 23, then 23 replace to 05.
So question here is: how to tell str_replace stop when finish first replace, do not loop.
Or there is any better solution for change timezone.
Please help.