如何更改单词的最后一个字母,如:
你还有10周的时间,我希望根据数字incrase改变周数,如果我想成为1:1周< - 如果是2,那么:2周< - 在echo结果中
我有这个过程:
function get_weeks_remaining($date, $expire){
$difference = strtotime($expire) - strtotime($date);
return floor($difference / 604800);
}
$link = mysqli_connect("localhost", "user", "pass", "table");
$nume = $user->data->username;
$id = $user->data->id;
$date = date('m/d/Y h:i:s a', time());
$expire_date = 'May 07, 2016';
$remain = get_weeks_remaining($date, $expire_date);
$sql = "SELECT `id`,`remain` FROM `week`";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
while(list($id,$remain) = mysqli_fetch_array($result)){
echo "you have $remain weeks left";
}
mysqli_free_result($result);
}
}
答案 0 :(得分:0)
while(list($id,$remain) = mysqli_fetch_array($result)){
if($remain > 0 and $remain < 2){
echo "you have $remain week left";
}else{
echo "you have $remain weeks left";
}
}
或只是做echo "you have $remain week/s left";
我希望这会对你有所帮助