我在下面有一个 stdClass 对象数组,但我想将这些项目合并到一个数组中,如下所示;
当前阵列
Array
(
[0] => stdClass Object
(
[photoid] => pht11a138355.jpg
[propertyid] => PTY698082F7A
[phototitle] => N/A
[photodescription] => N/A
[coverphoto] => 1
[photovisible] => 1
)
)
Array
(
[0] => stdClass Object
(
[photoid] => phtd9d04dc92.jpg
[propertyid] => PTY7419F7A38
[phototitle] => N/A
[photodescription] => N/A
[coverphoto] => 1
[photovisible] => 1
)
)
我想达到什么;
Array
(
[0] => stdClass Object
(
[photoid] => pht11a138355.jpg
[propertyid] => PTY698082F7A
[phototitle] => N/A
[photodescription] => N/A
[coverphoto] => 1
[photovisible] => 1
)
[1] => stdClass Object
(
[photoid] => phtd9d04dc92.jpg
[propertyid] => PTY7419F7A38
[phototitle] => N/A
[photodescription] => N/A
[coverphoto] => 1
[photovisible] => 1
)
)
是否可以在PHP中做到这一点
这是我正在使用的脚本的一部分;
foreach ($data['searchresults'] as &$row) {
$photo_array = $this->Properties_model->getimg($row->propertyid);
$photodata = $this->Properties_model->getimg($row->propertyid);
$data['photos'] = arrayToObject($photo_array);
echo '<pre>';
print_r($photo_array);
}