Riaan's SysAdmin Blog

My tips, howtos, gotchas, snippets and stuff. Use at your own risk!


php stdClass Object vs Array

Sometimes you may prefer handling your data like an object instead of an array. I prefer object style when I am working with code handling json from API's etc..

So instead of the $my_array["field1"] notation you can handle it as $my_array->field1.

Its pretyy simple just cast your array variable like this:

$data = (object) $my_array;

Better write up here:


Bio Info for Riaan