回答編集履歴
1
chousei
test
CHANGED
@@ -8,3 +8,28 @@
|
|
8
8
|
print_r($data);
|
9
9
|
```
|
10
10
|
DBにJSONデータを入れる意図もよくわかりません、普通に生データではだめなのでしょうか?
|
11
|
+
|
12
|
+
# 追記
|
13
|
+
ちょっと追記しておきます
|
14
|
+
```PHP
|
15
|
+
<?PHP
|
16
|
+
function htmlspecialchars_var_dump($str){
|
17
|
+
ob_start();
|
18
|
+
var_dump($str);
|
19
|
+
$res=ob_get_contents();
|
20
|
+
ob_end_clean();
|
21
|
+
print htmlspecialchars($res);
|
22
|
+
}
|
23
|
+
$arr = [];
|
24
|
+
$arr['key'] = '<table class="class"></table>';
|
25
|
+
$arr['key2'] = '<table class="class2"></table>';
|
26
|
+
$encode = json_encode($arr,JSON_HEX_TAG|JSON_HEX_QUOT|JSON_HEX_AMP|JSON_HEX_APOS|JSON_UNESCAPED_UNICODE);
|
27
|
+
$data=json_decode($encode,JSON_OBJECT_AS_ARRAY);
|
28
|
+
htmlspecialchars_var_dump($data);
|
29
|
+
```
|
30
|
+
結果:
|
31
|
+
```
|
32
|
+
array(2) { ["key"]=> string(29) "<table class="class"></table>" ["key2"]=> string(30) "<table class="class2"></table>" }
|
33
|
+
```
|
34
|
+
となるはずですがなりませんか?
|
35
|
+
|