我有與性病對象之前給出以及重新安排多維數組性病類對象
Array
(
[0] => abc_Object Object
(
[_api:protected] => zvbj
[_values:protected] => Array
(
[count] => 2
[data] => Array
(
[0] => abc_Charge Object
(
[_api:protected] => zvbj
[_values:protected] => Array
(
[id] => dGoEw
[ine] => fKYF0a
[xyz] => abc_Object Object
(
[_api:protected] => zvbj
[_values:protected] => Array
(
[id] => uUmuym
[last] => 4242
)
)
)
)
[1] => abc_Charge Object
(
[_api:protected] => zvbj
[_values:protected] => Array
(
[id] => dblvEw
[ine] => fKyyu0a
[xyz] => abc_Object Object
(
[_api:protected] => z7jj
[_values:protected] => Array
(
[id] => urtuym
[last] => 4242
)
)
)
)
)
)
)
[1] => abc_Object Object
(
[_api:protected] => zvbj
[_values:protected] => Array
(
[count] => 2
[data] => Array
(
[0] => abc_Charge Object
(
[_api:protected] => zvbj
[_values:protected] => Array
(
[id] => dGoEw
[ine] => fKYF0a
[xyz] => abc_Object Object
(
[_api:protected] => zvbj
[_values:protected] => Array
(
[id] => uUmuym
[last] => 4242
)
)
)
)
[1] => abc_Charge Object
(
[_api:protected] => zvbj
[_values:protected] => Array
(
[id] => dblvEw
[ine] => fKyyu0a
[xyz] => abc_Object Object
(
[_api:protected] => z7jj
[_values:protected] => Array
(
[id] => urtuym
[last] => 4242
)
)
)
)
)
)
)
)
我想所有這些組合成一個更簡單的數組作爲
一多維數組Array(
[0]=>(
[id] => dGoEw
[ine] => fKYF0a
[cid] => uUmuym
)
[1]=>(
[id] => dblvEw
[ine] => fKyyu0a
[cid] => urtuym
)
[2]=>(
[id] => dGoEw
[ine] => fKYF0a
[cid] => uUmuym
)
[3]=>(
[id] => dblvEw
[ine] => fKyyu0a
[cid] => urtuym
)
)
我已經嘗試了很多foreach循環和東西,但我甚至無法打印數組的第一個值。我不知道我錯過了什麼。
echo $arr['_api:protected'];
編輯
foreach($arr as $key=>$val)
{
echo $val['_api:protected'];
print_r($val['_values:protected']);
}
沒有輸出從這個甚至
foreach($arr as $key=>$val)
{
$aaa = $val['_values:protected']['data'];
$arr111['id'] = $aaa['_values:protected']['invoice'];
$arr111['ine'] = $aaa['_values:protected']['id'];
$arr111['cid'] = $aaa['_values:protected']['xyz']['_values:protected']['id'];
$arr222[] = $arr111;
}
print_r($arr222);
也沒有給我任何的輸出。任何人都可以告訴我我錯過了什麼?
請顯示你已經嘗試過... – DaveRandom 2012-02-10 11:36:54
@DaveRandom請看我的編輯。 – Astha 2012-02-10 11:43:14
你遇到的這個問題是因爲這些值是受保護的,並且你沒有在可訪問的上下文中這樣做。 'abc_Charge'是否擴展了'abc_Object'或反之呢? – DaveRandom 2012-02-10 11:50:42