Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once 'PhonebookEntry.php';
- class Phonebook {
- private $entries = array();
- public function add($entry) {
- $this->entries[] = $entry;
- }
- public function getSorted($direction) {
- $nameArray = array();
- $firstNameArray = array();
- $familyNameArray = array();
- $mobilePhoneArray = array();
- $homePhoneArray = array();
- for($i=0;$i<count($this->entries);$i++) {
- $firstNameArray[$i] = $this->entries[$i]->getFirstName();;
- }
- for($i=0;$i<count($this->entries);$i++) {
- $familyNameArray[$i] = $this->entries[$i]->getFamilyName();;
- }
- for($i=0;$i<count($this->entries);$i++) {
- $nameArray[$i] = "$firstNameArray[$i]". ' ' ."$familyNameArray[$i]<br />";
- }
- if($direction == 'asc') {
- asort($nameArray);
- }
- if($direction == 'desc') {
- arsort($nameArray);
- }
- $i = 0;
- for($i=0; $i < count($nameArray);$i++) {
- $mobilePhoneArray[$i] = $this->entries[$i]->getMobilePhone();
- $homePhoneArray[$i] = $this->entries[$i]->getHomePhone();
- }
- foreach($nameArray as $key => $value) {
- ?>
- <table style="border: 1px solid black; font-size: 11px; font-family: Tahoma;margin-bottom: 10px;" width="200" border="0" cellpadding="5" cellspacing="0"><tbody>
- <tr><td colspan="2" bgcolor="silver"><b><?php echo $nameArray[$key]; ?></b></td></tr>
- <?php if($mobilePhoneArray[$key] > 0){ ?>
- <tr><td>Mobile:</td><td><?php echo $mobilePhoneArray[$key]; ?></td></tr> <?php } ?>
- <?php if($homePhoneArray[$key] > 0){ ?>
- <tr><td>Home:</td><td><?php echo $homePhoneArray[$key]; ?></td></tr> <?php } ?>
- </tbody></table>
- <?php
- }
- }
- public function getByFirstLetter($letter) {
- }
- public function getByPhoneNumber($numberPart) {
- }
- }
- ?>
Add Comment
Please, Sign In to add comment