Morning all,
I've been writing a few pages over the last week (learning by doing) and I've been pretty successful so far. However i now have a problem that has boggled me for days and no amount of googling is helping.
<?php
// Define cache file
$cache_file = "cache.txt";
// Cache file is less than thirty minutes old.
if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 60 * 30 ))) {
// Don't bother refreshing, just use the file as-is.
$file = file_get_contents($cache_file);
// Our cache is out-of-date, so load the data from our remote server,
// and also save it over our cache for next time.
} else {
$file = file_get_contents('http://eu.battle.net/api/wow/guild/chamber-of-aspects/requiem%20paradisum?fields=achievements');
file_put_contents($cache_file, $file, LOCK_EX);
}
// Decode cache file
$achie = json_decode($file);
// Seperate achievements and timestamps as variables
$achiachi = ($achie->achievements->achievementsCompleted);
$achitime = ($achie->achievements->achievementsCompletedTimestamp);
foreach(array_combine($achiachi, $achitime) as $f => $n){
// Combine achievement number into Link for wowhead script
$achilink = ("http://www.wowhead.com/achievement=". $f);
// Sort out time formatting
$unix = ($n);
$not_unix = $unix / 1000;
$date = date("F d Y @ h:i A", $not_unix);
//Print into table
echo "
<table align=center class=mytable cellpadding=8 style=font-family:verdana;font-size:8pt;color:white;>
<tr>
<th>Achievement</th><th>Timestamp</th>
<tr>
<td><a href=\"$achilink\" rel=\"item=$achiachi\"></a></td>
<td>$date</td>
</tr>
</table>
";
}
?>
This does work for the most part . . . . but . . . . .when the arrays are printed it creates a new table for every array entry.
I'm expecting :
table1
header1 - header2
achievement1 - achievement time
achievement2 - achievement time
achievement3 - achievement time
achievement4 - achievement time
I'm getting :
table1
header1 - header2
achievement1 - achievement time
table2
header1 - header2
achievement2 - achievement time
table3
header1 - header2
achievement3 - achievement time
table4
header1 - header2
achievement4 - achievement time
Most annoying! If someone could tell me what the chuff I've done wrong I'd be very appreciative.
Thanks
John