Fatal error: An iterator cannot be used with foreach by reference in D:\OpenServer\domains\Site\index.php on line 20
$query = "SELECT * FROM man_cats";
$result = mysqli_query($connect, $query);
function buildTree($result) {
$childs = array();
foreach($result as &$item) {
$childs[$item['parent_id']][] = &$item;
unset($item);
}
foreach($result as &$item) {
if (isset($childs[$item['id']])) {
$item['childs'] = $childs[$item['id']];
}
}
return $childs[0];
}
buildTree($result);
Здесь начинается 20 строчка -
foreach($result as &$item) {
$childs[$item['parent_id']][] = &$item;
unset($item);
}