-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathram.php
34 lines (31 loc) · 825 Bytes
/
ram.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 Ram {
public $name;
public $price;
public function __construct($name, $price) {
$this->name = $name;
$this->price = $price;
}
function getRamInformation($limitPrice, $ramType) {
$rows = array_map ( 'str_getcsv', file ( 'data/computer/Ram.csv' ) );
$header = array_shift ( $rows );
$csv = array ();
$data = array ();
$ramData = array ();
foreach ( $rows as $row ) {
$csv [] = array_combine ( $header, $row );
}
foreach ( $csv as $ramData ) {
$value = floatval ( $ramData ['Price'] );
if ($value <= $limitPrice && $value > 0 && $ramType === $ramData ['Ramtype']) {
array_push ( $data, $ramData );
}
}
$sort = new sort();
$sort->sortArray ( $data, 'Price' );
$name = $data [0] ['Name'];
$price = $data [0] ['Price'];
return new Ram ( $name, $price );
}
}
?>