-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhdd.php
34 lines (32 loc) · 807 Bytes
/
hdd.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
class Hdd {
public $name;
public $price;
public function __construct($name, $price) {
$this->name = $name;
$this->price = $price;
}
function getHddInformation($limitPrice) {
// get vga has closest price
$rows = array_map ( 'str_getcsv', file ( 'data/computer/HDD.csv' ) );
$header = array_shift ( $rows );
$csv = array ();
$data = array ();
$hddData = array ();
foreach ( $rows as $row ) {
$csv [] = array_combine ( $header, $row );
}
foreach ( $csv as $hddData ) {
$value = floatval ( $hddData ['Price'] );
if ($value <= $limitPrice && $value > 0) {
array_push ( $data, $hddData );
}
}
$sort = new sort();
$sort->sortArray ( $data, 'Price' );
$name = $data [0] ['Name'];
$price = $data [0] ['Price'];
return new Hdd ( $name, $price);
}
}
?>