Goal: retrieve an element of data from within a PHP object by number.
This is the print_r($data) of the object:
stdClass Object ( [0] => stdCl
this works for PHP5+
echo $data[0]->UserName;
or
foreach ($data as $data){ echo $data->UserName; }
or as suggested by @orrd
current($data)->UserName works great too.