douweiluo0600 2014-05-21 04:56 采纳率: 0%
浏览 30
已采纳

php问题中的数组格式

I have an array like:

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

Now, I need to change the key "place" in the array in such a way that its either like: [place] => Spain or [place] => Array ( [0] => Spain )

Basically, I have to change it to the same format the other keys are in the array. Can anybody help me? I'm new to this.

  • 写回答

1条回答 默认 最新

  • dongye6377 2014-05-21 04:58
    关注
    $arr['place'] = $arr['place']->country->answer
    

    or your other way:

    $arr['place'] = array( $arr['place']->country->answer )
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?