Search

Cast array to object PHP

> Array to object
> Array to stdClass

Description
Cast array to object


$object = (object)$array;
$object = new stdClass();
foreach ( $array as $key => $value ) {
    $object->$key = $value;
}
$object = json_decode(json_encode($array), FALSE);
SEE ALSO