If I perform the following query:

```
$lookupConnection = DB::connection(PZ_CONNECTION)->table($this->createLookupTable);
$lookupConnection->addSelect($lookupField);
$lookupConnection->where($searchField['data_lookup'], '=', $searchArray[$searchField['js_name']]);
$goodData = $lookupConnection->get();
dd($goodData);

```

This will work, and display an array containing an object.

```
Array(1) {
    [0] => 
    object(stdClass)#225 (2) {
    ["foo"] => string(3) "bar"
    }
    }

```

My problem is this, how do I access elements of the object without knowing what the element is?

I mean, the field is stored in $lookupField, however, I cannot run:

```
echo $goodData[0]->$lookupField

```

And if I try

```
echo $goodData[0][$lookupField]

```

I also get an error.

But if I try

```
echo $goodData[0]->foo

```

Then it works. But thats no good, as I don't know until runtime what the contents of $lookupField will be. I need to either output the query as an array, or access the object data via a variable, but I don't know how.