-
Notifications
You must be signed in to change notification settings - Fork 0
/
california.php
executable file
·85 lines (63 loc) · 1.88 KB
/
california.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
//http://cdec.water.ca.gov/misc/monthly_res.html
/*
include 'simple_html_dom.php';
$file = 'data/california.csv';
$fh = fopen($file, 'a');
if(!filesize($file)) {
fputcsv($fh, array('reservoir', 'capacity', 'storage', 'storage_change', 'pct_capacity', 'avg_storage', 'pct_avg', 'storage_last_year', 'date'));
}
// Data from California Data Exchange Center
$path = 'http://cdec.water.ca.gov/cgi-progs/reservoirs/RES';
$html = new simple_html_dom();
$html->load_file($path);
$date_rows = $html->find('h1+h3');
$date = preg_split('/-/', $date_rows[0]->plaintext);
$rows = $html->find('tr');
$reservoirs = array();
foreach($rows as $row) {
$capacity = $row->find('td',2);
$cap = $capacity->plaintext;
if(preg_match('/\d$/', $cap)) {
$site = $row->find('td', 0);
$reservoirs['site'] = $site->plaintext;
$reservoirs['capacity'] = $cap;
$storage = $row->find('td', 4);
$reservoirs['storage'] = $storage->plaintext;
$change = $row->find('td', 5);
$reservoirs['change'] = $change->plaintext;
$pct_capacity = $row->find('td', 6);
$reservoirs['pct_capacity'] = $pct_capacity->plaintext;
$avg_storage = $row->find('td', 7);
$reservoirs['avg_storage'] = $avg_storage->plaintext;
$pct_avg = $row->find('td', 8);
$reservoirs['pct_avg'] = $pct_avg->plaintext;
$year_ago = $row->find('td', 11);
$reservoirs['year_ago'] = $year_ago->plaintext;
$reservoirs['date'] = trim($date[1]);
fputcsv($fh, $reservoirs);
}
}
fclose($fh); */
$values = array(
"Blue Mesa",
"Crystal",
"Vallecito",
"Rifle Gap",
"Taylor Park",
"Jackson Gulch",
"Lemon",
"Morrow Point",
"Navajo",
"Vega",
"Silver Jack",
"Ridgway",
"Paonia",
"McPhee",
"Fruitgrowers",
"Elephant Butte",
);
sort($values);
foreach($values as $key => $value) {
echo '<option value="' . $value . '">' . "\n";
}