The following query:
$years_sql="
SELECT YEAR(FROM_UNIXTIME(field_id_34)) AS start_date
FROM exp_channel_data
WHERE channel_id = 5
GROUP BY YEAR(FROM_UNIXTIME(field_id_34))
";
$query = $this->EE->db->query($years_sql);
$years = $query->result_array();
$tagdata = $this->EE->TMPL->tagdata;
$data = array(
"years" => $years
);
$variables = array();
$variables[] = $data;
return $this->EE->TMPL->parse_variables($tagdata, $variables);
Outputs:
Array ( [0] => Array ( [start_date] => 2015 ) [1] => Array ( [start_date] => 2016 ) )
I want to output each item in the array (2014, 2015) in the 'year' variable.
How can I have it so if I have the plugin loop, with the 'year' variable in it, it loops through the array and outputs the two years? Is it possible to use a 'foreach' statement for the variables?