그냥 개발자 블로그

PHP팀 - post json 데이터 받기 본문

프로그래밍팁/php

PHP팀 - post json 데이터 받기

마음이파파 2015. 10. 11. 20:29

function objectToArray($d) {

if (is_object($d)) {

// Gets the properties of the given object

// with get_object_vars function

$d = get_object_vars($d);

}

 

if (is_array($d)) {

/*

* Return array converted to object

* Using __FUNCTION__ (Magic constant)

* for recursive call

*/

return array_map(__FUNCTION__, $d);

}

else {

// Return array

return $d;

}

}

 

 

$post = json_decode(file_get_contents('php://input'));

$post = objectToArray($post); 

 

echo $post->변수명;