My API call returns following data in Codeigniter:
Pronamic\Twinfield\VatCode\VatCode Object
(
[code:Pronamic\Twinfield\VatCode\VatCode:private] => IH
[name:Pronamic\Twinfield\VatCode\VatCode:private] => BTW 21%
)
Pronamic\Twinfield\VatCode\VatCode Object
(
[code:Pronamic\Twinfield\VatCode\VatCode:private] => IL
[name:Pronamic\Twinfield\VatCode\VatCode:private] => BTW 6%
)
Pronamic\Twinfield\VatCode\VatCode Object
(
[code:Pronamic\Twinfield\VatCode\VatCode:private] => IN
[name:Pronamic\Twinfield\VatCode\VatCode:private] => BTW 0%
)
Pronamic\Twinfield\VatCode\VatCode Object
(
[code:Pronamic\Twinfield\VatCode\VatCode:private] => VH
[name:Pronamic\Twinfield\VatCode\VatCode:private] => BTW 21%
)
Pronamic\Twinfield\VatCode\VatCode Object
(
[code:Pronamic\Twinfield\VatCode\VatCode:private] => VL
[name:Pronamic\Twinfield\VatCode\VatCode:private] => BTW 6%
)
Pronamic\Twinfield\VatCode\VatCode Object
(
[code:Pronamic\Twinfield\VatCode\VatCode:private] => VN
[name:Pronamic\Twinfield\VatCode\VatCode:private] => BTW 0%
)
My (simple?) question is how to modify this result so it handles like a normal array, with values like:
'code' => 'IH', 'name' => BTW 21%
Any clue?
Thx in advance!
I did following and it works. First changed object to regular array.
foreach ($result as $array_item) {
$item = (array) $array_item;
$keys = array_keys($item);
$key_first = $keys[0];
$key_second = $keys[1];
echo $item[$key_first];
echo $item[$key_second];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.