I am trying to add values to an array using the code below but it only seems to result in 1 item (last in the loop) being added to the array.
$awin_products = array();
foreach($awinprices as $value){
foreach($value as $obj){
$awin_products[name] = (string)$obj->sName;
$awin_products[imageUrl] = (string)$obj->sAwThumbUrl;
}
}
print_r($awin_products);
This is probably quite simple to fix but so far I've not found an answer.
EDIT: I am looking for this output:
Array
(
[0] => Array
(
[name] => Item 1 Name
[imageUrl] => http://example.com/item1.jpg
)
[1] => Array
(
[name] => Item 2 Name
[imageUrl] => http://example.com/item2.jpg
)
[2] => Array
(
[name] => Item 3 Name
[imageUrl] => http://example.com/item3.jpg
)
[3] => Array
(
[name] => Item 4 Name
[imageUrl] => http://example.com/item4.jpg
)
)