Reputation: 2052
I have a foreach loop that goes through to get information related to a photo.
It's basically this
foreach($medias as $image) {
$fullImage = $image->imageHighResolutionUrl;
$standardRes = $image->imageStandardResolutionUrl;
$caption = $image->caption;
$createdTime = date("Y-m-d",$image->createdTime);
$imageCode = $image->code;
}
Now I want to put that data into an array (I'm assuming), so I can sort it by $createdTime then loop through the data to run an "INSERT INTO table" mysql query for each photo.
Upvotes: 0
Views: 44
Reputation: 623
I think you can store the data into an array by the following way -
$sl = 0;
foreach($medias as $image) {
$data[$sl]['fullImage'] = $image->imageHighResolutionUrl;
$data[$sl]['standardRes'] = $image->imageStandardResolutionUrl;
$data[$sl]['caption'] = $image->caption;
$data[$sl]['createdTime'] = date("Y-m-d",$image->createdTime);
$data[$sl]['imageCode'] = $image->code;
$sl++;
}
echo print_r($data);
Now you can a sort the $data variable whatever you want. Then loop through the data and entry into Database.
let me know if you any problem there.
Upvotes: 1