我正在解析下面的xml
object(SimpleXMLElement)#23 (5) {
["version"]=>
string(1) "2"
["data"]=>
object(SimpleXMLElement)#21 (4) {
["record"]=>
array(28) {
[0]=>
object(SimpleXMLElement)#20 (6) {
["name"]=>
string(1) "1"
["line"]=>
string(1) "1"
}
[1]=>
object(SimpleXMLElement)#19 (6) {
["name"]=>
string(1) "2"
["line"]=>
string(1) "2"
}
.....
代码非常简单,工作正常
if(is_object($xml->data->record) && sizeof($xml->data->record)>0)
{
$counter=0;
foreach($xml->data->record as $key => $record)
{
$name = (string)$record->name;
$line = (string)$record->line;
}
}
问题是我找不到获取数组密钥0,1的方法,我需要它们。
关于foreach返回记录的$ key
["record"]=>
array(28) {
[0]=>
object(SimpleXMLElement)#20 (6) {
}
[1]=>
object(SimpleXMLElement)#19 (6) {
}
任何帮助表示赞赏