0

I have found while i was surfing the intent a function that shows how long a topic was posted.

this is the function:

```
function RelativeTime($timestamp){
$difference = time() - $timestamp;
$periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
$lengths = array("60","60","24","7","4.35","12","10");
if ($difference > 0) { // this was in the past
$ending = "ago";
} else { // this was in the future
$difference = -$difference;
$ending = "time to go";
}
for($j = 0; $difference >= $lengths[$j]; $j++) $difference /= $lengths[$j];
$difference = round($difference);
if($difference != 1) $periods[$j].= "s";
$text = "$difference $periods[$j] ";
return $text;
}
```

what i want to do is control which name goes with which number. For instance when minute is between 2 and 9 print (minutes).

so I put this code:

```
if ($lengths[2] >= 3 && $lengths[2] <= 11) {
$periods[2] = "hours";
}
if ($lengths[2] = 25) {
$periods[2] = "twenty five hour";
}
if ($lengths[3] > 2 && $lengths[3] < 11) {
$periods[3] = "days";
}
if ($lengths[3] = 2) {
$periods[3] = "two days";
}
```

the problem is that the array are not affected by the condition that i put after "if" and all other values become same (if i view all the topics in a list).

any solutions