function mailboxes($start = ""){
global $imap, $do_not_show;
static $tree,$name,$array;
$dont_show = array("Slettet", "Sendt post");
if(!empty($do_not_show)){
$dont_show = array_merge($do_not_show,$dont_show);
}
$list = imap_getmailboxes($imap, "{localhost:143/novalidate-cert}$start", "%");
if (is_array($list)) {
$info = array();
$space = " ";
foreach ($list as $key => $val) {
$spaces = substr_count($start, ".");
$spaces = str_repeat($space, $spaces);
$name = str_replace("{localhost:143/novalidate-cert}".$start, "", $val->name);
$name = str_replace(".", "", $name);
//$tree .= $spaces.$name."
";
$info['name'] = $name;
$info['name_wspaces'] = $spaces.$name;
$info['full_path'] = $val->name;
if(!in_array($name, $dont_show)){
$array[] = $info;
}
if (!($val->attributes & LATT_HASNOCHILDREN)) {
if(empty($start)){
$next = $start;
} else{
$next = $start . ".";
}
$go = $next . $name;
mailboxes($go, 0);
}
}
}
$the_return = $array;
return $the_return;
}
print "1. time(correct):
";
$list = mailboxes("INBOX");
if (is_array($list)) {
foreach ($list as $key) {
$path = str_replace("{localhost:143/novalidate-cert}", "", $key['full_path']);
echo $key['name_wspaces'] . "
\n";
}
}
print "
";
print '2. time(with unset($array) before function call:
';
unset($array);
$list = mailboxes("INBOX");
if (is_array($list)) {
foreach ($list as $key) {
$path = str_replace("{localhost:143/novalidate-cert}", "", $key['full_path']);
echo $key['name_wspaces'] . "
\n";
}
}
print "
";
print "3. time:
";
$list = mailboxes("INBOX");
if (is_array($list)) {
foreach ($list as $key) {
$path = str_replace("{localhost:143/novalidate-cert}", "", $key['full_path']);
echo $key['name_wspaces'] . "
\n";
}
}
print "
";
print "4. time:
";
$list = mailboxes("INBOX");
if (is_array($list)) {
foreach ($list as $key) {
$path = str_replace("{localhost:143/novalidate-cert}", "", $key['full_path']);
echo $key['name_wspaces'] . "
\n";
}
}
print "
";
?>