hi everyone I want make new 1 array dimension from array 2 dimension and the code like this:
[0] => Array(
[photo_data_id] => 0
[photo_image] => Array
(
[0] => 37a.jpg
)
[photo_status] => 1
)
[1] => Array(
[photo_data_id] => 1
[photo_image] => Array
(
[0] => 6.jpg
[1] => 6a.jpg
[2] => 20141001_073231.jpg
)
[photo_status] => 1
)
[2] => Array(
[photo_data_id] => 2
[photo_image] => Array
(
[0] => 20.jpg
[1] => 21.jpg
[2] => 22.jpg
[3] => 23.jpg
[4] => 24.png
)
[photo_status] => 1
)
and the result i want like below and than store into database:
[0] => Array(
[photo_data_id] => 0
[photo_image] => 37a.jpg
[photo_status] => 1
)
[1] => Array(
[photo_data_id] => 1
[photo_image] => 6.jpg
[photo_status] => 1
)
[2] => Array(
[photo_data_id] => 1
[photo_image] => 6a.jpg
[photo_status] => 1
)
[3] => Array(
[photo_data_id] => 1
[photo_image] => 20141001_073231.jpg
[photo_status] => 1
)
[4] => Array(
[photo_data_id] => 2
[photo_image] => 20.jpg
[photo_status] => 1
)
[5] => Array(
[photo_data_id] => 2
[photo_image] => 21.jpg
[photo_status] => 1
)
[6] => Array(
[photo_data_id] => 2
[photo_image] => 22.jpg
[photo_status] => 1
)
[7] => Array(
[photo_data_id] => 2
[photo_image] => 23.jpg
[photo_status] => 1
)
[8] => Array(
[photo_data_id] => 2
[photo_image] => 24.jpg
[photo_status] => 1
)
please help me, i am a newbie, thank's before :)
$result = array();
foreach ($array1 as $item) {
foreach ($item['photo_image'] as $image) {
$result[] = array(
'photo_data_id' => $item['photo_data_id'],
'photo_image' => $image,
'photo_status' => $item['photo_status'],
);
}
}
print_r($result);