-
Notifications
You must be signed in to change notification settings - Fork 4
/
lookup_array_build.php
42 lines (33 loc) · 1.06 KB
/
lookup_array_build.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
<?php
$xml=simplexml_load_file("Date-Wise-Prices-all-Commodity.xml");
$xml = dom_import_simplexml($xml);
$nodelist= $xml->getElementsByTagName('Table');
for($i = 0; $i < $nodelist->length; $i++) {
$commodity_name[$i] =$nodelist->item($i)->getElementsByTagName('Commodity')->item(0)->nodeValue;
$district_name[$i] =$nodelist->item($i)->getElementsByTagName('District')->item(0)->nodeValue;
$market_name[$i] =$nodelist->item($i)->getElementsByTagName('Market')->item(0)->nodeValue;
}
echo "<pre>";
$cval = "\$commodity_name = array(";
foreach (array_unique($commodity_name) as $c){
$cval .= "'".$c."',";
}
$cval .= ");";
print $cval."<BR><BR>";
$cval = "\$district_name = array(";
foreach (array_unique($district_name) as $c){
$cval .= "'".$c."',";
}
$cval .= ");";
print $cval."<BR><BR>";
$cval = "\$market_name = array(";
foreach (array_unique($market_name) as $c){
$cval .= "'".$c."',";
}
$cval .= ");";
print $cval."<BR><BR>";
#print_r(array_unique($commodity_name));
#print_r(array_unique($district_name));
#print_r(array_unique($market_name));
echo "<pre>";
?>