Be very careful!
If you try something like
$array = array(5, 2, 3);
$object = (object)$array;
print_r($object);
echo $object->2;
you'll end up with
PHP Parse error: syntax error, unexpected T_LNUMBER, expecting T_STRING or T_VARIABLE or '{' or '$' in - on line 5
Really, the safest way to convert from arrays to objects is pretty convoluted but works alright:
public function makeObjects($data)
{
$object = (object) $data;
foreach ($object as $property)
{
if (is_array($property)) $this->makeObjects($property);
}
return $object;
}