Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Person {
- private $name;
- private $age;
- private $occupation;
- public function __construct(string $name, int $age, string $occupation)
- {
- $this->name = $name;
- $this->age = $age;
- $this->occupation = $occupation;
- }
- }
- $persons = [];
- $occupations = [];
- while (true){
- $line = explode(' ', trim(fgets(STDIN)));
- if ($line[0] == 'END'){
- break;
- }
- $name = $line[0];
- $age = intval($line[1]);
- $occupation = $line[2];
- $person = new Person($name, $age, $occupation);
- $persons[$name] = $age;
- $occupations[$name] = $occupation;
- }
- $count = 0;
- asort($persons);
- foreach ($persons as $name => $age){
- echo $name . ' - age: ' . $age . ', occupation: ' . $occupations[$name] . "\r\n";
- $count++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement