Reputation: 109
Given this object, how do I output the value of pipe|title?
stdClass Object
(
[profile|title] => John Doe
)
I've never seen a pipe in a member name before.
Upvotes: 6
Views: 57
Reputation: 3717
You can use
$obj->{'profile|title'}
Since you're just using it as a stupid data store, you can also cast it as an array
$arr = (array) $obj;
$arr['profile|title'];
This would be more useful if you're using a lot of values out of it this way or you need to iterate over it.
Upvotes: 5
Reputation:
You can make use of the curly brackets and put the field name in a string:
$obj->{'profile|title'}
Upvotes: 6