stdClass -> Array 로 바꾸는 법.
<?php
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;
}
}
?>
Array -> stdClass
<?php
function arrayToObject($d) {
if (is_array($d)) {
/*
* Return array converted to object
* Using __FUNCTION__ (Magic constant)
* for recursive call
*/
return (object) array_map(__FUNCTION__, $d);
}
else {
// Return object
return $d;
}
}
?>
<?php
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;
}
}
?>
Array -> stdClass
<?php
function arrayToObject($d) {
if (is_array($d)) {
/*
* Return array converted to object
* Using __FUNCTION__ (Magic constant)
* for recursive call
*/
return (object) array_map(__FUNCTION__, $d);
}
else {
// Return object
return $d;
}
}
?>
게시글 목록
| 번호 | 제목 |
|---|---|
| 32729 | |
| 32718 | |
| 32717 | |
| 32714 | |
| 32713 | |
| 32709 | |
| 32706 | |
| 32705 | |
| 32702 | |
| 32693 | |
| 32685 | |
| 32680 | |
| 32659 | |
| 32643 | |
| 32636 | |
| 32629 | |
| 32619 | |
| 32618 | |
| 32617 | |
| 32611 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기