php class Notebook var property array class Class construction Constru

 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
<?php
class Notebook {
var $property = array(
'class' => 'Class',
'construction' => 'Construction',
'diagonal' => 'Diagonal',
'matrix-type' => 'Matrix-type',
'resolution' => 'Resolution',
'processor' => 'Processor',
'frequency' => 'Frequency',
'ram' => 'RAM',
'video-card' => 'Video-card',
'harddisc' => 'Harddisc',
'ssd' => 'SSD',
'weight' => 'Weight',
'os' => 'OS',
'item_added' => 'Item added'
);
function parse_from_html($html) {
$parsed_data_from_html = explode('<em>&bull;</em>', $html);
$i = 0;
foreach ($this->property as $key => $value) {
if ($key == 'ssd' && count($parsed_data_from_html) == 13) continue;
$this->$key = $parsed_data_from_html[$i];
$i++;
}
}
function html_result() {
$result = '';
foreach ($this->property as $key => $value) {
$result .= $value . ': ' . $this->$key . ' <br />';
}
return $result;
}
}