function ArraySearchRecursive($Needle, $Haystack, $NeedleKey, $Strict = false, $Path = array()) { if (!is_array($Haystack)) { return false; } foreach ($Haystack as $Key => $Val) { if (is_array($Val) && ($SubPath = ArraySearchRecursive($Needle, $Val, $NeedleKey, $Strict, $Path))) { $Path = array_merge($Path, array($Key), $SubPath); return $Path; } elseif (!$Strict && $Val == $Needle && $Key == (strlen($NeedleKey) > 0 ? $NeedleKey : $Key) || $Strict && $Val === $Needle && $Key == (strlen($NeedleKey) > 0 ? $NeedleKey : $Key)) { $Path[] = $Key; return $Path; } } return false; }
$temp[$x]['parent'] = $dev->ParentDevice; $temp[$x]['rights'] = $dev->Rights; $cabtemp[$dev->Cabinet]['name'] = ""; ++$x; if ($dev->ParentDevice != 0) { $childList[$dev->ParentDevice] = ""; // Create a list of chassis devices based on children present } } } } // Anything in the childList is assumed to be chassis device with children present. // Change type to chassis if (isset($childList)) { foreach ($childList as $key => $blank) { $a = ArraySearchRecursive($key, $temp, 'devid'); if (is_array($a)) { $temp[$a[0]]['type'] = 'chassis'; // Device already in the list so set it to chassis } else { // Device doesn't exist so we need to add it to the list for display purposes $dev->DeviceID = $key; $dev->GetDevice(); $temp[$x]['devid'] = $dev->DeviceID; $temp[$x]['label'] = $dev->Label; $temp[$x]['type'] = 'chassis'; $temp[$x]['cabinet'] = $dev->Cabinet; $temp[$x]['parent'] = $dev->ParentDevice; $temp[$x]['rights'] = $dev->Rights; $cabtemp[$dev->Cabinet]['name'] = ""; ++$x;