nogdod,
here is how the array comes out, there is merely test data in there now, but that is how it comes from LDAP and below is how i'm currently doing it. it works, sort of, but with two thousand plus values, it doesn't run fully, it times out, even after 5 minutes...
can you think of a better way to loop through this, if you run it as it is right now, you'll see the desired results
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<pre>
<?
$arrall = array(array(array("president"),array(1111),array(1111)),array(array("vicepresident"),array(1111),array(2222)),array(array("Manager1"),array(2222),array(3333)),array(array("Manager2"),array(2222),array(4444)),array(array("Supervisor1"),array(3333),array(5555)),array(array("Supervisor2"),array(4444),array(6666)),array(array("Supervisor3"),array(4444),array(7777)),array(array("Supervisor4"),array(4444),array(8888)),array(array("Employee1"),array(5555),array(1212)),array(array("Employee2"),array(7777),array(2323)),array(array("Employee3"),array(6666),array(3434)),array(array("Employee4"),array(6666),array(4545)));
function crawlArray($lastrep) {
global $arrlisted;
global $arrall;
global $treepush;
$reportsto = $lastrep;
for($z=0;$z<count($arrall);$z++) {
if ($arrall[$z][1][0] == $reportsto) {
echo $treepush . "|_" . $arrall[$z][0][0] . "-" . $reportsto . "-" . $arrall[$z][2][0] . "<br>";
$lastreport = $reportsto;
$lasttree = $treepush;
$reportsto = $arrall[$z][2][0];
$treepush .= " ";
unset($arrall[$z][1][0]);
crawlArray($reportsto);
$reportsto = $lastreport;
$treepush = $lasttree;
}
}
}
for($i=0;$i<count($arrall);$i++) {
if ($arrall[$i][1][0] == $arrall[$i][2][0]) {
$toptitle = $arrall[$i][0][0];
$topreports = $arrall[$i][1][0];
$topnumber = $arrall[$i][2][0];
}
}
$treepush = "";
$reportsto = $topnumber;
$arrlisted = array();
crawlArray($reportsto);
?>
</pre>
</body>
</html>