function myfunc ()
{
$a['foo'] = 'bar';
$a['baz'] = 'qux';
return $a;
}
How do you do it so that when you call $a = myfunc(); you can use echo $a->foo; and it will output bar?
Additional question: Having that simple function above, is it better to return an array or object?
Just cast it as an object.
As for which one you want, it’s up to you. It depends on what you are doing with the returned object or array.