Hi,
This is weird, I have tried your example code and it works fine. The complete scenario of what I am trying to do is of course more complicated than I gave in my first example, but I can't see why this weird behaviour is happening. Here is the bigger picture:
I am retrieving an array of result objects from a query and I am trying to write a function that will retrieve the properties of all the objects. So I am looping over the array and then using the properties from each result object. In an attempt to make the function more generic, I thought passing in a property name would be useful. I do a check before trying to retrieve a property to see that it exists, and it does:
if(property_exists($result, $value) && property_exists($result, $display)){
print("<option value=\"$result->$value\" >$result->$display</option>");
}
but this outputs '->$display' in the select options. And I also get the PHP error:
"Object of class stdClass could not be converted to string"
What is the obvious thing I am missing here?
Thanks,
Stephen