function get_contacts() { $directory = new DirectoryObj(); $contacts = $directory->load_all_contacts(); $output = array(); foreach ($contacts as $contact) { $departments = array(); foreach ($contact->departments as $dept) { $departments[] = $dept->deptname; } $output[] = array($contact->cid, $contact->fullname, $contact->firstname, $contact->middlename, $contact->lastname, implode("; ", $departments), $contact->email, $contact->phone, $contact->phone2, $contact->tags); } return $output; }