Sha256: cebe42405c89b2df77c1eb9dcafb3e343594041df80219aec4d5fa6f35603200
Contents?: true
Size: 777 Bytes
Versions: 276
Compression:
Stored size: 777 Bytes
Contents
<?php class School { private $database = array() ; public function numberOfStudents() { return (count($this->database, COUNT_RECURSIVE) - count($this->database)) ; } public function add($student, $grade) { $this->database[$grade][] = $student ; } public function grade($grade) { return (array_key_exists($grade, $this->database) ? $this->database[$grade] : array()) ; } public function studentsByGradeAlphabetical() { $tmp = $this->database ; ksort($tmp) ; foreach ($tmp as $grade => $students) { asort($students) ; foreach ($students as $student) { $res [ $grade ][] = $student ; } } return $res ; } }
Version data entries
276 entries across 276 versions & 1 rubygems