<?
$date_today = strtotime(date("Y-m-d"));
/*
* Тут начинается цикл $products as $product
*/
if (timeInDate($product['created']) === $date_today){
$products1++;
}
if (timeInDate($product['created']) === ($date_today-86400)){
$products2++;
}
if (timeInDate($product['created']) === ($date_today-86400*2)){
$products3++;
}
if (timeInDate($product['created']) === ($date_today-86400*3)){
$products4++;
}
$date = [
$date_today => $products1,
($date_today-86400) => $products2,
($date_today-86400*2) => $products3,
($date_today-86400*3) => $products4,
];
$date_today = strtotime(date('Y-m-d'));
$iproducts = $date = array();
foreach ($products as $product) {
for ($i = 0; $i <= 11; $i++) {
if (timeInDate($product['created']) === ($date_today-86400*$i)) {
if (array_key_exists($i, $iproducts)) {
$iproducts[$i]++;
}
else {
$iproducts[$i] = 1;
}
}
}
}
for ($i = 0; $i <= 11; $i++) {
if (array_key_exists($i, $iproducts)) {
$date[] = array($date_today-86400*$i => $iproducts[$i]);
}
}
echo '<pre>';
print_r($date);
echo '</pre>';