Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $infoCompanies = [];
- $cmd = explode(' -> ', readline());
- while ($cmd[0] !== 'End') {
- list($company, $employee) = $cmd;
- if (!key_exists($company, $infoCompanies)) {
- $infoCompanies[$company] = [];
- }
- if (!in_array($employee, $infoCompanies[$company])) {
- $infoCompanies[$company][] = $employee;
- }
- $cmd = explode(' -> ', readline());
- }
- ksort($infoCompanies);
- foreach ($infoCompanies as $companyId => $users) {
- echo $companyId . PHP_EOL;
- foreach ($users as $user) {
- echo "-- $user" . PHP_EOL;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement