API响应:名称中带有连字符的访问成员


API response: Access member with hyphen in name

我的处境很荒谬。我正在使用一个API谁返回给我

[winner-id] => 15404899

我从API的返回中选择元素的方式是:

$matches->returnElement;

问题是,当我输入

时,我无法获得winner-id的值
$matches->winner-id;

由于(-)符号,它是无效变量。你能给我一些建议吗?

试试这个:

$matches->{'winner-id'};