I have some values that grab off an API and store them into an array $data for insertion into my tables. However, I seem to have objects within the array $data, which seems kind of messy. Is it possible to convert all the contents of array $data into array elements?
PHP Code
$data['title'] = $item->ItemAttributes->Title;
$data['brand'] = $item->ItemAttributes->Brand;
$data['color'] = $item->ItemAttributes->Color;
echo "<pre>";
print_r($data);
Output
stdClass Object
(
[title] => stdClass Object
(
[0] => La Martina Polo Shirt Scotland Polo, Color: Black, Size: L
)
[brand] => stdClass Object
(
[0] => La Martina
)
[color] => stdClass Object
(
[0] => Black
)
)
$data? Was it initialized as an array ? Can you recreate the problem on codepad.viper-7.com ?$datais just an empty array.$datausing$data[] = $obj,$databecomes an array$itemis not an array, because you are calling$item->ItemAttributes->Title;.