switch ($word) { case 'negative': $this->negative = -1; break; case 'hundred': $this->hundred = $this->ones * 100; $this->reset(0, $this->hundred, $this->thousand); break; case 'thousand': $this->thousand = ($this->hundred + $this->ones) * 1000; $this->reset(0, 0, $this->thousand); break; case 'million': $this->million = ($this->thousand + $this->hundred + $this->ones) * 1000000; $this->reset(0, 0, 0); break; default: $this->ones = $this->numbers[$word] + $this->ones; break; } } } $fh = fopen($argv[1], "r"); while (!feof($fh)) { $val = fgets($fh); if ($val != "") { $obj = new Number(trim($val)); echo $obj->generateNumber() . PHP_EOL; } } fclose($fh);