質問編集履歴

2

追記②

2020/07/05 12:44

投稿

satokibi
satokibi

スコア5

test CHANGED
File without changes
test CHANGED
@@ -116,4 +116,18 @@
116
116
 
117
117
  var_dump($genre);
118
118
 
119
+
120
+
121
+ 追記➁ foreach文追加
122
+
123
+ ```PHP
124
+
125
+ foreach($genre as $a => $b){
126
+
127
+ echo $b;
128
+
129
+ }
130
+
119
131
  ```
132
+
133
+ ```

1

foreach文追加

2020/07/05 12:44

投稿

satokibi
satokibi

スコア5

test CHANGED
File without changes
test CHANGED
@@ -70,10 +70,50 @@
70
70
 
71
71
  ```PHP
72
72
 
73
- Notice: Trying to get property 'result' of non-object in F:\programing\xampp\htdocs\test\test01.php on line 16
73
+ Notice: Trying to get property 'result' of non-object in F:********.php on line 16
74
74
 
75
75
  ```
76
76
 
77
77
 
78
78
 
79
79
  大変恐れ入りますがよろしくお願い致します。
80
+
81
+
82
+
83
+ 追記 foreach文を追加
84
+
85
+ ```PHP
86
+
87
+ $xml = simplexml_load_file($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
88
+
89
+
90
+
91
+ var_dump((array)$xml);
92
+
93
+
94
+
95
+ $item_list = $xml->result->items->item;
96
+
97
+ foreach($item_list as $item){
98
+
99
+ $genre[]=$item -> iteminfo -> genre ->item -> name;
100
+
101
+
102
+
103
+
104
+
105
+ $a = "<div>
106
+
107
+ ◆ジャンル:$genre[0]<BR>
108
+
109
+ </div>";
110
+
111
+ echo $a;
112
+
113
+ }
114
+
115
+ var_dump($xml);
116
+
117
+ var_dump($genre);
118
+
119
+ ```