I have the following function that runs well when executed in view of Yii;
function formatTree($tree, $parent){
$tree2 = array();
foreach($tree as $i => $item)
{
if($item['parent'] == $parent)
{
$tree2[$item['id_produto_categoria']] = $item;
$tree2[$item['id_produto_categoria']]['submenu'] = formatTree($tree, $item['id_produto_categoria']);
}
}
return $tree2;
}
The problem started when I wrote the above function in the model, to better separate the codes, did so; (model)
Error: Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 261900 bytes) in C:\Apache2.2\htdocs\yiiadministracao\protected\modules\administracao\models\ProdutosCategorias.php on line 71
public function getCategoriasFormatted($value, $parent)
{
$tree2 = array();
foreach($value as $i => $item)
{
if($item['parent'] == 0)
{
$tree2[$item['id_produto_categoria']] = $item;
(LINE 71) $tree2[$item['id_produto_categoria']]['submenu'] = $this->getCategoriasFormatted($value, $item['id_produto_categoria']);
}
}
return $tree2;
}
Can anyone help?