1. php json_encode() 함수를 사용하여 json문자열로 변환
// PHP배열 $fruits = array("strawberry"=>"딸기", "banana"=>"바나나", "apple"=>"사과"); $fruits_json = json_encode($fruits);
// javascript let js_fruits = =$fruits_json?>; console.log(js_fruits); for (let val in js_fruits) { console.log(val); // 딸기 console.log(js_fruits[val]); //strawberry }