Fido Fido - 6 months ago 9
PHP Question

last letter change based on number incrase

How can i change the last letter of an word like:

You have 10 weeks left, well i want to change weeks to week based on number incrase if is 1 i want to be: 1 week<- and if 2, to be : 2 weeks<- in echo result

I have this process:

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";

If is there a trick for this it will be nice for me. Thanks!

while(list($id,$remain) = mysqli_fetch_array($result)){
 if($remain > 0 and $remain < 2){
   echo "you have $remain week left";
   echo "you have $remain weeks left";

or just do echo "you have $remain week/s left";
i hope this will help you