Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2. $files = glob('*.txt');
  3. $stack = array();
  4. foreach ($files as $file) {
  5.         $content = substr(file_get_contents($file), 0, -1);
  6.         $students = array_unique(explode('|', $content));
  7.         foreach ($students as $student) {
  8.                 if (empty($student) === true) {
  9.                         continue;
  10.                 }
  11.                 if (array_key_exists($student, $stack) === false) {
  12.                         $stack[$student] = 1;
  13.                 } else {
  14.                         $stack[$student] = $stack[$student] + 1;
  15.                 }
  16.         }
  17. }
  18. asort($stack);
  19.  
  20. foreach ($stack as $k => $v) {
  21.         echo sprintf('%s était là durant %d séances'."\n", $k, $v);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement