02 JSON data exchange

02 JSON data exchange

Javascript array to PHP
javascript

var where= ["apple","banana"];
var whereString = JSON.stringify(where);
console.log(whereString);
var myObject = JSON.parse(myJSONString);

php

$array1= array("apple","banana");
$arrayStr1=json_encode($array1);
print($arrayStr1);     // "["apple","banana"]"
$array2=json_decode($arrayStr1);
var_dump($array2);
javascript
01 String 字串CH04 ArrayCH05 時間日期Ch10 AJAX