更新时间:2023-02-04 08:56:59
我想通了.json_encode 处理对象的方式与字符串不同.我将对象转换为字符串,现在可以使用了.
I figured it out. json_encode handles objects differently than strings. I cast the object to a string and it works now.
foreach($xml->children() as $state)
{
$states[]= array('state' => (string)$state->name);
}
echo json_encode($states);