2014-05-21 90 views
0

我有這樣的數組:陣列格式

Array 
(
    [name] => Linda 
    [place] => stdClassObject 
     { 
     [country] => stdClassObject 
      (
       [answer] => Spain 
      ) 
     } 
    [age] => 16 
    [gender] => Array 
     (
      [0] => female 
    ) 
) 

現在,我需要改變陣列中的鍵「地點」以這樣的方式,它的任一這樣的: [位] =>西班牙 或 [位] =>數組 ( [0] =>西班牙 )

基本上,我必須把它更改爲相同的格式的其它鍵是在數組中。有誰能夠幫助我?我對此很陌生。

+0

$陣列[ '地方'] = 「西班牙」; – superphonic

回答

2
$arr['place'] = $arr['place']->country->answer 

或您的其他方式:

$arr['place'] = array($arr['place']->country->answer) 
+0

謝謝......我明白了:) – user2509780