Good day! I've been attempting to resolve the error specified in the title for some time now - hence why I need your help!
I know this error arises due to the PHP version I'm on being <5.4.* (I think). Unfortunately I'm no expert on PHP <5.4 (XAMPP is on >) and I've been trying to use this 'array' (as can be seen below) but still I'm having issues when putting it particular code (sourced from the internet of course) into my website.
function timetostr($timestamp) {
$age = time() - $timestamp;
if ($age == 0)
return "just now";
$future = ($age < 0);
$age = abs($age);
$age = (int)($age / 60); // minutes ago
if ($age == 0) return $future ? "momentarily" : "just now";
$scales = array(
["minute", "minutes", 60],
["hour", "hours", 24],
["day", "days", 7],
["week", "weeks", 4.348214286], // average with leap year every 4 years
["month", "months", 12],
["year", "years", 10],
["decade", "decades", 10],
["century", "centuries", 1000],
["millenium", "millenia", PHP_INT_MAX]
);
foreach ($scales as list($singular, $plural, $factor)) {
if ($age == 0)
return $future
? "in less than 1 $singular"
: "less than 1 $singular ago";
if ($age == 1)
return $future
? "in 1 $singular"
: "1 $singular ago";
if ($age < $factor)
return $future
? "in $age $plural"
: "$age $plural ago";
$age = (int)($age / $factor);
}
}
Please note that there 'array' part used to be '['s! Any help is appreciated!
Thanks in advance!
/edit Why on earth was this marked as a duplicate if I've done what is shows there and it clearly isn't working / the only example even remotely close is for the newer version of php. I've already tried what is says there with little success, I require help.