I think the verbage is a little wrong for your question, but I think are looking to accomplish something like this:
echo getData($id)->someArrayOffset;
While you can do this with mysql_fetch_object, I'll show you how you can do this using ArrayObject in PHP5, or by returning your own object in PHP 4 so that you can find a usefulness for it outside of function that return objects for you. Here's your same function using ArrayObject in PHP5:
function getData($id) {
// mysql query
return new ArrayObject( mysql_fetch_array($result) );
}
echo getData($id)->name;