I’m using curl to fetch some data from a website. After I process it I manage to get it to this state:
Array (
[GraphicRiver] => Array ( [0] => stdClass Object
(
[id] => 698515
[item] => Alien Icons Set
[url] => http://graphicriver.net/item/alien-icons-set/698515
[user] => chaoscod3r
[thumbnail] => http://2.s3.envato.com/files/23574322/Thumb.jpg
[sales] => 5
[rating] => 0
[cost] => 5.00
[uploaded_on] => Mon Oct 24 17:16:20 +1100 2011
[tags] => alien icons, clean icons, easy editing, icons pack, minimalist icons pack, resizable, simple icons, vector icons, vector shapes
[category] => icons/miscellaneous
[live_preview_url] => http://3.s3.envato.com/files/23574321/Preview.jpg
)
)
)
but what I want to have instead of that stdClass Object is Array, so how do I rewrite this kind of array to make that object and array ?
This is the method I’m using to get what’s above:
public function all_items_by_site($user_name) {
$items_by_marketplace = $this->user_items_by_site($user_name);
$marketplaces = array();
$items = array();
foreach ($items_by_marketplace as $key) {
$marketplaces[] = array(
'Marketplace' => $key->site,
'Items' => $key->items
);
}
foreach ($marketplaces as $key) {
$items[$key['Marketplace']] = $this->new_files_from_user($user_name, $key['Marketplace']);
}
return $items;
}
I’m using this api wrapper as base api wrapper for what I want to develop: https://github.com/JeffreyWay/Envato-Marketplace-API-Wrapper-in-PHP .
You can easily cast
stdClassobjects to an array:In your concrete case that would be: