更新:如何从标记数组中隐藏标记?
Updated: How to hide marker from a marker array?
我有一个邮政编码数组 $d,这会生成我的 google 地图的标记。
我只想显示创建时间少于 3 秒的标记,超过 3 秒的标记将被隐藏。
$postcodes = array();
$diff = array(); // time difference variable
foreach($stmt as $x){
//////////////time calculation start////////////////////////////
$posts[] = $x['date'];
$timePosted = new DateTime($posts[] = $x['date']);
echo 'Time Posted : '. $timePosted ->format("d-m-Y H:i:s");
echo "</br>";
date_default_timezone_set('Europe/London');
$today = date('d-m-Y H:i:s');
echo 'Current time is : '. $today;
echo "</br>";
$today = new DateTime(date('d-m-Y H:i:s'));
$interval = $timePosted->diff($today);
"Difference " . $interval->d. " days ". $interval->h. " hours ".$interval->i." minutes ".$interval->s." seconds ";
echo "</br>";
//$diff[] = $interval->h. " hours ".$interval->i." minutes ".$interval->s." seconds ";
$diff[] = $interval->s; //last array seconds
/////////////////////time calculation finish here/////////////////////////
global $postcodes;
//$postcodes[] = $x['postcode']; //postcodes
foreach ($diff as $time => $seconds) {
echo var_dump($seconds);
if($seconds >=3){
echo "larger than 3 seconds<br />";
}else{
echo "smaller than 3 seconds.<br />";
$postcodes[] = $x['postcode']; //this need to be globle not working yet
}
}//time foreach loop finish here
} /// main foreach loop finish here
$d=' "'.implode('","',$postcodes).'"'; //postcodes inside $postcode array
我不敢相信这会这么简单,事实证明我根本不需要在 php 中写这个,我可以在 SQL 中完成所有我需要的是将 date >= now() - INTERVAL 3 second;
添加到我的 sql 语句中。希望这可以帮助某人。
我有一个邮政编码数组 $d,这会生成我的 google 地图的标记。 我只想显示创建时间少于 3 秒的标记,超过 3 秒的标记将被隐藏。
$postcodes = array();
$diff = array(); // time difference variable
foreach($stmt as $x){
//////////////time calculation start////////////////////////////
$posts[] = $x['date'];
$timePosted = new DateTime($posts[] = $x['date']);
echo 'Time Posted : '. $timePosted ->format("d-m-Y H:i:s");
echo "</br>";
date_default_timezone_set('Europe/London');
$today = date('d-m-Y H:i:s');
echo 'Current time is : '. $today;
echo "</br>";
$today = new DateTime(date('d-m-Y H:i:s'));
$interval = $timePosted->diff($today);
"Difference " . $interval->d. " days ". $interval->h. " hours ".$interval->i." minutes ".$interval->s." seconds ";
echo "</br>";
//$diff[] = $interval->h. " hours ".$interval->i." minutes ".$interval->s." seconds ";
$diff[] = $interval->s; //last array seconds
/////////////////////time calculation finish here/////////////////////////
global $postcodes;
//$postcodes[] = $x['postcode']; //postcodes
foreach ($diff as $time => $seconds) {
echo var_dump($seconds);
if($seconds >=3){
echo "larger than 3 seconds<br />";
}else{
echo "smaller than 3 seconds.<br />";
$postcodes[] = $x['postcode']; //this need to be globle not working yet
}
}//time foreach loop finish here
} /// main foreach loop finish here
$d=' "'.implode('","',$postcodes).'"'; //postcodes inside $postcode array
我不敢相信这会这么简单,事实证明我根本不需要在 php 中写这个,我可以在 SQL 中完成所有我需要的是将 date >= now() - INTERVAL 3 second;
添加到我的 sql 语句中。希望这可以帮助某人。