我正在使用搜索索引器,并将索引器中的搜索结果作为包含多个对象的数组A.这些对象是从索引器生成的特殊对象,不能用于输出目的。有没有办法将它转换为包含标准PHP ojbects的数组$ B?谢谢!
数组A:
Array ( [0] => XSDocument Object ( [_data:XSDocument:private] => Array ( [id] => 65 [message] => cool book awesome [username] => lost guy [book] => my love....
[1] => XSDocument Object ( [_data:XSDocument:private] => Array ( [id] => 78 [message] => cool book awesome [username] => lost guy [book] => my love....)
非常感谢!
答案 0 :(得分:0)
您在每个循环中覆盖数据,因此您必须写入$B
类似于数组。
$B = array();
foreach ($A as $row) {
$tmp = array();
$tmp['username'] = $row->username;
$tmp['book'] = $row->book;
$tmp['message'] = $row->message;
$B[] = $tmp;
}