Skip to content

Instantly share code, notes, and snippets.

@rummelonp
Created April 13, 2011 06:38
Show Gist options
  • Save rummelonp/917075 to your computer and use it in GitHub Desktop.
Save rummelonp/917075 to your computer and use it in GitHub Desktop.
stdClassを連想配列に変換する程度の関数
<?php
function stdClassToArray($obj)
{
if (!is_object($obj) && !is_array($obj)) {
return $obj;
}
$arr = (array)$obj;
foreach ($arr as $key => $value) {
unset($arr[$key]);
$key = str_replace('@', '', $key);
$arr[$key] = stdClassToArray($value);
}
return $arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment