2014-05-21 92 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