Reputation: 177
I have code like :
$result = $object->property[0];
but I want to do something like :
if ($a) {
$property = 'blue' }
else {
$property = 'black'}
$result = $object->$property[0];
However this give me a Cannot use string offset as an array
error.
Any pointers (no pun intended) appreciated.
Upvotes: 2
Views: 1473