I have an stdClass Object array below, but I want to merge the items into a single array as show below;
Current Array
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
)
)
What I would like to achieve;
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
)
)
Is it possible to do it in PHP
This is part of the script that I am using;
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);
}
Try this :