function.php

388 ワード

1.配列をオブジェクトに変換
function array_to_obj($array){
    $obj = new stdClass();
    foreach ($array as $key => $value){
        if (is_array($value)){
            $obj->$key = $this->array_to_obj($value);
        } else {
            $obj->$key = $value;
        }
    }
    return $obj;
}