rendered paste body<?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."<br>"; $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):<br><br>";$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'] . "<br>\n"; }}print "<br><br><br>";print '2. time(with unset($array) before function call:<br><br>';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'] . "<br>\n"; }}print "<br><br><br>";print "3. time:<br><br>";$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'] . "<br>\n"; }}print "<br><br><br>";print "4. time:<br><br>";$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'] . "<br>\n"; }}print "<br><br><br>";?>