-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathparser.php
More file actions
86 lines (76 loc) · 2.03 KB
/
Copy pathparser.php
File metadata and controls
86 lines (76 loc) · 2.03 KB
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
86
<?php
function objectsIntoArray($arrObjData, $arrSkipIndices = array())
{
$arrData = array();
// if input is object, convert into array
if (is_object($arrObjData)) {
$arrObjData = get_object_vars($arrObjData);
}
if (is_array($arrObjData)) {
foreach ($arrObjData as $index => $value) {
if (is_object($value) || is_array($value)) {
$value = objectsIntoArray($value, $arrSkipIndices); // recursive call
}
if (in_array($index, $arrSkipIndices)) {
continue;
}
$arrData[$index] = $value;
}
}
return $arrData;
}
?>
<?php
$xmlUrl = "event.xml"; // XML feed file/URL
$xmlStr = file_get_contents($xmlUrl);
$xmlObj = simplexml_load_string($xmlStr);
$arr = objectsIntoArray($xmlObj);
$event=$arr['Event'];
$echo="";
$i=0;
foreach($event as $key=>$value){
if($i==0){
$echo.="<div class=\"{$key}\">\n";
$i++;
}
else
$echo.="<div class=\"{$key} nothing\">\n";
foreach($value as $key1=>$value1){
$setter=0;
if(is_array($value1)){
foreach($value1 as $key2=>$value2){
if(is_array($value2)){
$setter++;
}
}
if($setter==0 && $value1!=Array()){
// print_r($value1);
$echo.="\t<div>\n";
$echo.="\t\t<div class=\"event_sub_title\">{$value1['title']}</div>\n";
$echo.="\t\t<p>{$value1['description']}</p>\n";
$echo.="\t</div>\n";
}
else if($value1!=Array() && $setter!=0){
$echo.="\t<div class=\"{$key1}undefined\">\n";
foreach($value1 as $key2=>$value2){
if(is_array($value2)){
$echo.="\t<div>\n";
$echo.="\t\t<div class=\"event_sub_title\">{$value2['title']}</div>\n";
$echo.="\t\t<p>{$value2['description']}</p>\n";
$echo.="\t</div>\n";
}
}
$echo.="\t</div>\n";
}
}
else if($value1!=Array()){
$echo.="\t<div>\n";
$echo.="\t\t<div class=\"event_sub_title\">{$value['title']}</div>\n";
$echo.="\t\t<p>{$value['description']}</p>\n";
$echo.="\t</div>\n";
}
}
$echo.="</div>\n";
}
echo $echo;
?>