I just want to know how to remove duplicate Year/Month from the code below.
//Function to return unique year for index menu:
function get_year()
{
$date = months_years();
while ($row = mysqli_fetch_array($date)){
$rows[]= explode('-', $row['date']);
}
foreach ($rows as $row){
$y[] = $row;
}
for ($e = 0; $e < count($y); $e++)
{
$duplicate = null;
for ($ee = $e+1; $ee < count($y); $ee++)
{
if (strcmp($y[$ee][0],$y[$e][0]) === 0)
{
$duplicate = $ee;
break;
}
}
if (!is_null($duplicate))
array_splice($y,$duplicate,1);
}
foreach ( $y as $k=>$v)
{
$y[$k] ['year'] = $y[$k][0];unset($y[$k][0]);
$y[$k] ['months'] = $y[$k][1];unset($y[$k][1]);
$y[$k] ['day'] = $y[$k][2];unset($y[$k][2]);
}
foreach ($y as $k)
{
extract($k);
echo "<a href='index.php?year=".$year."&month=".$_GET['month']."'title='Select Year to Display'>".$year."</a> ";
}
}
OUTPUT:
Calendar
1970 2014 2014 2014 2014 2014 2014
01 08 09 09 09 09 10 10
Thanks and Hoping someone could help me.