avlist = array();
while ($i <= count ($avlist_tmp)) {
$this->avlist[$k][$j] = $avlist_tmp[$i];
++$j;
++$i;
if ($j > 2) {
$j = 0;
++$k;
}
}
}
function displaylist () { //display the list, with gender headers
function ofgender ($gender, $list) { //internal function, to avoid dupe code
for ($i = 0; $i < count ($list); ++$i) {
if ($list[$i][1] == $gender) {
echo " ".$list[$i][2].": ".$list[$i][0]."
\n";
}
}
}
echo "Male
\n"; //male avs
ofgender ("m", $this->avlist);
echo "
Female
\n"; //female avs
ofgender ("f", $this->avlist);
echo "
Non-human
\n"; //nonhuman avs
ofgender ("n", $this->avlist);
}
}
/* Call like this:*/
$lstGen = new avList;
$lstGen->readlist ("avlist.txt");
$lstGen->displaylist();
/* Do not use the functions without initing the class (ie: avList::function) */
?>