-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssd.php
46 lines (44 loc) · 1.08 KB
/
ssd.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
35
36
37
38
39
40
41
42
43
44
45
46
<?php
class Ssd {
public $name;
public $price;
public function __construct($name, $price) {
$this->name = $name;
$this->price = $price;
}
function getSsdInformation($limitPrice) {
// if ($price > 0) {
// if ($m2Slot) {
// // Get ssd type = m2
// // get ssd closest price
// return new Ssd ( $name, $price );
// } else {
// // get ssd type = normal
// // get ssd closest price.
// return new Ssd ( $name, $price );
// }
// } else {
// return null;
// }
$rows = array_map ( 'str_getcsv', file ( 'data/computer/SSD.csv' ) );
$header = array_shift ( $rows );
$csv = array ();
$data = array ();
$ssdData = array ();
foreach ( $rows as $row ) {
$csv [] = array_combine ( $header, $row );
}
foreach ( $csv as $ssdData ) {
$value = floatval ( $ssdData ['Price'] );
if ($value <= $limitPrice && $value > 0) {
array_push ( $data, $ssdData );
}
}
$sort = new sort();
$sort->sortArray ( $data, 'Price' );
$name = $data [0] ['Name'];
$price = $data [0] ['Price'];
return new Ssd ( $name, $price);
}
}
?>