Fastest way to Convert Associative Arrays to Objects

Simply cast an Associative array:

1
2
3
4
5
$obj = (object) array('animal' => 'dog', 'name' => 'simon');

// Then you can access values as objects:
echo $obj->animal; // Outputs dog
echo $obj->name; // Outputs simon

No need to create a class or Function to accomplish it.