回答編集履歴
1
追記
test
CHANGED
@@ -47,3 +47,77 @@
|
|
47
47
|
|
48
48
|
|
49
49
|
あとは適当に関数に埋め込んでやってください。
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
**追記**
|
54
|
+
|
55
|
+
```php
|
56
|
+
|
57
|
+
<?php
|
58
|
+
|
59
|
+
function get_arr(){
|
60
|
+
|
61
|
+
$arr = [
|
62
|
+
|
63
|
+
'test' => [
|
64
|
+
|
65
|
+
[ 'key'=>'tset1', 'label'=>'テスト1' ],
|
66
|
+
|
67
|
+
[ 'key'=>'tset2', 'label'=>'テスト2' ]
|
68
|
+
|
69
|
+
],
|
70
|
+
|
71
|
+
'post' => [
|
72
|
+
|
73
|
+
[ 'key'=>'post1', 'label'=>'ポスト1', 'sub'=>true ],
|
74
|
+
|
75
|
+
[ 'key'=>'post2', 'label'=>'ポスト2', 'sub'=>false ],
|
76
|
+
|
77
|
+
],
|
78
|
+
|
79
|
+
];
|
80
|
+
|
81
|
+
return $arr;
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
function get_base_arr( $type, $want ){
|
88
|
+
|
89
|
+
$arr = get_arr();
|
90
|
+
|
91
|
+
$result = [];
|
92
|
+
|
93
|
+
foreach( $arr[$type] as $key=>$val ){
|
94
|
+
|
95
|
+
$result[] = $val[$want];
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
return $result;
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
function hoge(){
|
106
|
+
|
107
|
+
$arr = get_arr();
|
108
|
+
|
109
|
+
foreach($arr['post'] as $val){
|
110
|
+
|
111
|
+
$mokuteki[$val['key']] = $val['label'];
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
return ($mokuteki);
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
var_export(hoge());
|
122
|
+
|
123
|
+
```
|