Переменная $result подсчитывает количество записей, в данном случае он грузит на 2 секунды.
Код: Выделить всё
if ($post['sub_category_id'] == $chi['id']) {
$result[] = $post;
}
Код: Выделить всё
<?php
$result = [];
foreach ($category as $categ) {
echo '<h4>' . $categ['name'] . '</h4>';
foreach ($children as $chi) {
if ($chi['root'] == $categ['id']) {
foreach ($posts as $post) {
if ($post['sub_category_id'] == $chi['id']) {
$result[] = $post;
}
}
?>
<a href=<?php echo $chi['title_translite'];?>> <?php echo $chi['name']; ?>(<?php echo count($result); ?>)</a>
<?php
$result = array();
}
}
}
?>