回答編集履歴

1

ついき

2022/05/19 08:52

投稿

yambejp
yambejp

スコア114843

test CHANGED
@@ -12,3 +12,20 @@
12
12
  <?PHP
13
13
  $data=filter_input(INPUT_POST,"data",FILTER_DEFAULT,FILTER_REQUIRE_ARRAY);
14
14
  print_r($data);
15
+ ```
16
+ # json経由
17
+ データをjsonにまとめるならこう
18
+ ```javascript
19
+ const url = './sample2.php';
20
+ const data = ["111.111.111.111", "222.222.222.222"];
21
+ const body = new FormData();
22
+ body.append("data",JSON.stringify(data));
23
+ const method='post';
24
+ fetch(url,{method,body}).then(res=>res.text()).then(console.log);
25
+ ```
26
+ //sample2.php
27
+ ```PHP
28
+ <?PHP
29
+ $data=filter_input(INPUT_POST,"data");
30
+ print_r(json_decode($data));
31
+ ```