<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content="text/html; charset=iso-8859-1" http-equiv=Content-Type> <META name=GENERATOR content="MSHTML 8.00.6001.22967"> <STYLE></STYLE> </HEAD><FONT face=Arial><FONT size=2> <BODY> <DIV>sveiki, </DIV> <DIV> </DIV> <DIV>padariau savo pirmaja rekursija, kuri formuoja multidimensional masyva.veikti tai lyg viskas veikia, ale pvz 6000 irasu suka ~20 sekundziu, o 12000 - isvis nesulaukiau... </DIV> <DIV>taigi, kas negerai su sia funckija? slieku savo jegomis daugiau nerandu, bo neesu itin geras egzpertas :)</DIV> <DIV> </DIV> <DIV><? </DIV> <DIV>function get_child($data, $pid = null) {<BR> $tree = array();<BR> <BR> foreach( $data as $key => $d ) {<BR> if( $d['parent_id'] == $pid ) {<BR> <BR> $tree[$d['id']] = array<BR> (<BR> 'parent_id' => $d['parent_id']<BR> );<BR> <BR> unset($data[$key]);<BR> <BR> $children = $this->get_child($data, $d['id']);<BR> <BR> if($children) {<BR> <BR> $tree[$d['id']]['children'] = $children;<BR> <BR> }<BR> <BR> }<BR> }<BR> return $tree;<BR> } </DIV> <DIV>?></DIV></BODY></HTML></FONT></FONT>