tooted=array(); $f=fopen("tooted2.txt", "r"); while($rida=fgets($f, 100)){ $m=explode(",", $rida); array_push($this->tooted, array($m[0], floatval($m[1]))); } } function teave(){ return "Ostuandmete klass"; } function toodeteLoetelu(){ $t=""; foreach($this->tooted as $toode){ $t.="\n"; } $t.="
".htmlspecialchars($toode[0])." $toode[1]
"; return $t; } } $korv=new Ostukorv(); echo $korv->toodeteLoetelu();