以下に stdClass オブジェクト配列がありますが、以下に示すように項目を 1 つの配列にマージしたいと考えています。
現在の配列
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);
}