Associated array problem
Posted: Wed Feb 24, 2010 6:19 am
I've got a function that lists pages from several directories. However, I am having trouble ordering them (at present, they're ordered as groups from their respective parents, rather than collectively as I want):
If you look at the commented array that I try to print at the bottom, you can see I have tried to return an ordered list by adding my results to an associated members array as an alternative, however it appears to duplicate the results.
Can anyone help!?
Code: Select all
<div class="members">
<ul>
<?php
$members = array();
function snippet_fullmenu($parent){
global $members;
$out = '';
$childs = $parent->children(null, array(), true);
$exclude = array("");
if (count($childs) > 0){
foreach ($childs as $child)
/* Don't display specific pages */
if(!in_array($child->breadcrumb(),$exclude)){
$depth = substr_count($child->link(), '/');
if($depth == 7){
$split_name = explode(" ", $child->title());
$surname = isset($split_name[2]) ? $split_name[2] : $split_name[1];
$entry = '<li>'.$child->link($child->breadcrumb.', '.$child->content('practice')).', '.$surname.'</li>'."\r";
$out .= $entry;
$members[$surname] = $entry;
}
$out .= snippet_fullmenu($child);
}
}
return $out;
}
?>
<?php
echo snippet_fullmenu($this->find('/members/'));
//ksort($members);
//echo $members['Louw'];
//foreach ($members as $s => $value){
//print $count++;
//print($value . "<br>");
//}
?>
</ul>
</div>Can anyone help!?