質問編集履歴

4

ついk

2020/10/12 14:19

投稿

otyatya_no_tya
otyatya_no_tya

スコア10

test CHANGED
File without changes
test CHANGED
@@ -48,7 +48,7 @@
48
48
 
49
49
  "datasets": [{
50
50
 
51
- "labels": "1",
51
+ "labels": "123",
52
52
 
53
53
  "backgroundColor": "RGBA(225, 95, 150, 0.5)",
54
54
 
@@ -62,7 +62,7 @@
62
62
 
63
63
  {
64
64
 
65
- "labels": "2",
65
+ "labels": "234",
66
66
 
67
67
  "backgroundColor": "RGBA(225, 95, 150, 0.5)",
68
68
 

3

追記

2020/10/12 14:19

投稿

otyatya_no_tya
otyatya_no_tya

スコア10

test CHANGED
File without changes
test CHANGED
@@ -112,7 +112,7 @@
112
112
 
113
113
  foreach($arr->data->chart->datasets as $data) {
114
114
 
115
- echo $data->{'labels'}[0];
115
+ echo $data->{'labels'}[1];
116
116
 
117
117
  }
118
118
 

2

追記

2020/10/12 14:18

投稿

otyatya_no_tya
otyatya_no_tya

スコア10

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  phpでjsonの値を取り出したい。
6
6
 
7
- chart->datasets->labelsの値を取り出したい。
7
+ chart->datasets[1]->labelsの値を取り出したい。
8
8
 
9
9
 
10
10
 

1

追記

2020/10/12 14:17

投稿

otyatya_no_tya
otyatya_no_tya

スコア10

test CHANGED
File without changes
test CHANGED
@@ -14,31 +14,11 @@
14
14
 
15
15
  ```
16
16
 
17
- Notice: Trying to get property 'datasets' of non-object in C:.php on line 23
17
+ チャート
18
18
 
19
19
 
20
20
 
21
- Notice: Trying to get property 'labels' of non-object in C:.php on line 23
22
-
23
-
24
-
25
- Notice: Trying to get property 'datasets' of non-object in C:php on line 23
26
-
27
-
28
-
29
- Notice: Trying to get property 'labels' of non-object in C:.php on line 23
30
-
31
-
32
-
33
- Notice: Trying to get property 'datasets' of non-object in C:.php on line 23
34
-
35
-
36
-
37
- Notice: Trying to get property 'labels' of non-object in C:.php on line 23
38
-
39
-
40
-
41
- object(stdClass)#3 (3) { ["name1"]=> string(4) "aaaa" ["labels"]=> array(5) { [0]=> string(3) "aaa" [1]=> string(3) "bbb" [2]=> string(3) "ccc" [3]=> string(3) "ddd" [4]=> string(3) "eee" } ["datasets"]=> array(2) { [0]=> object(stdClass)#4 (5) { ["labels"]=> string(1) "1" ["backgroundColor"]=> string(23) "RGBA(225, 95, 150, 0.5)" ["borderColor"]=> string(19) "RGBA(225,95,150, 1)" ["borderWidth"]=> int(1) ["pointBackgroundColor"]=> string(15) "RGB(46,106,177)" } [1]=> object(stdClass)#5 (5) { ["labels"]=> string(1) "2" ["backgroundColor"]=> string(23) "RGBA(225, 95, 150, 0.5)" ["borderColor"]=> string(19) "RGBA(225,95,150, 1)" ["borderWidth"]=> int(1) ["pointBackgroundColor"]=> string(15) "RGB(46,106,177)" } } }
21
+ 12
42
22
 
43
23
  ```
44
24
 
@@ -130,9 +110,9 @@
130
110
 
131
111
  <?php
132
112
 
133
- foreach($arr->data->chart as $chart) {
113
+ foreach($arr->data->chart->datasets as $data) {
134
114
 
135
- echo $chart->{'name1'}->{'labels'};
115
+ echo $data->{'labels'}[0];
136
116
 
137
117
  }
138
118